public static void main (String[] args) {
int a = 0010;
String num = Integer.toString(a);
System.out.println(num);
}
Why does it print 8 not 0010?
public static void main (String[] args) {
int a = 0010;
String num = Integer.toString(a);
System.out.println(num);
}
Why does it print 8 not 0010?
Integers are stored in binary form in memory. There are several ways to define integer literal. 0010
is octal, in base 8. toString
prints in base 10 (decimal).