I am trying out a simple program for printing characters. When I do this:
import java.io.*;
public class listit {
public static void main(String[] args) {
for (int i = 32; i < 127; i++) {
System.out.write(i);
// break line after every eight characters.
if (i % 8 == 7) System.out.write('\n');
else System.out.write('\t');
}
System.out.write('\n');
}
}
I am getting the expected result, that is, the printable subset of the ASCII character set is being printed out. However, when I try something similar:
import java.io.*;
public class listit {
public static void main(String[] args) {
int i = 122;
System.out.write(i);
}
}
I am getting no output at all, while I was expecting z. How is this program different from the one above, save the absence of a loop?