Friday, July 3, 2015

Clarification about “int” number that begins with Zero in java

public class Test {

    public static void main(String[] args) {

        int i = 012;
        System.out.println(i);
    }
}


It will print 10. but why?


the trick is "If a number starts with 0 it's an octal number with base 8. 012 is in decimal a 10"

No comments:

Post a Comment