RosettaCodeData/Task/Non-decimal-radices-Output/Java/non-decimal-radices-output.java

12 lines
470 B
Java
Raw Permalink Normal View History

2013-04-10 23:57:08 -07:00
public static void main(String args[]){
for(int a= 0;a < 33;a++){
System.out.println(Integer.toBinaryString(a));
System.out.println(Integer.toOctalString(a));
System.out.println(Integer.toHexString(a));
//the above methods treat the integer as unsigned
//there are also corresponding Long.to***String() methods for long's.
System.out.printf("%3o %2d %2x\n",a ,a ,a); //printf like the other languages; binary not supported
}
}