To get the octal representation of a number, you need to either pass the radix to Integer.toString(int, int)
method, or use Integer.toOctalString(int)
method:
int a = 15;
String s = Integer.toOctalString(a);
System.out.println(Integer.parseInt(s));
Integer.parseInt(String, int)
parses the string using the given radix. You don't want that. The output you are asking for is just the representation of the number in base 8
.