You need to pass the same number of arguments as you have flags in your printf.
for (int c = 0; c < 128; c++) {
// String hex = Integer.toString(c , 16); - No need for this anymore.
// Print the output with printf to create the columns
// character (c), string(s), decimal integer(d)
System.out.printf("%-2c 0x%-2X %-2d%n", (char)c, c, c);
}
With 0x%-2X
, you can print out uppercase Hex values. I added 0x
as a prefix to specify the base.
Example output:
...
A 0x41 65
B 0x42 66
C 0x43 67
D 0x44 68
E 0x45 69
F 0x46 70
G 0x47 71
H 0x48 72
I 0x49 73
J 0x4A 74
K 0x4B 75
L 0x4C 76
M 0x4D 77
N 0x4E 78
O 0x4F 79
P 0x50 80
Q 0x51 81
R 0x52 82
S 0x53 83
T 0x54 84
U 0x55 85
V 0x56 86
W 0x57 87
X 0x58 88
Y 0x59 89
Z 0x5A 90
...