Java examples for Language Basics:Number Format
Using the # flag with conversion characters o and x.
public class Main { public static void main(String[] args) { /*from ww w. j a va 2s .c o m*/ int c = 31; // initialize c System.out.printf("%#o\n", c); System.out.printf("%#x\n", c); } }