// // File: /home/cs255001/demo/atoi/ConvInt2Digits.java // // Converting a binary number between 0 and 99 to a String // public class ConvInt2Digits { public static void main(String[] args) throws Exception { int i; char[] c = new char[2]; // char array of size 1 // (because we only have 1 character) i = 67; // *** Change to any value between 0 and 99 c[0] = (char) (i/10 + 48); // c[0] is the left most digit in number i c[1] = (char) (i%10 + '0'); // c[1] is the right most digit in number i /* --------------------------------------------- Make a string out of the character(s) ---------------------------------------------- */ String s = new String(c); System.out.println(">>> " + s); /* --------------------------------------------- Prove to students that s is a string ---------------------------------------------- */ s = s + 10000; System.out.println(">>> " + s); } }