Question: What are the largest integer and long literals allowed by the Java compiler? Bonus points for explaining what is odd about them, and a possible reason that the Java design team allowed this seeming inconsistency.
PS: There are two answers, either of which I would consider correct.
Comments
==== SPOILERS ====
Fortunately, Java has half-way decent docs available online:
http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#48282
"The largest decimal literal of type int is 2147483648 (2^31). All decimal literals from 0 to 2147483647 may appear anywhere an int literal may appear, but the literal 2147483648 may appear only as the operand of the unary negation operator -."
(and likewise for longs).
To me, that seems quite sensible. Did you have anything else in mind when asking the question?
Yep. That's one correct answer, but I notice you didn't go for bonus points :(
Try it in hex ;-)
(Yes, I once wrote a Java compiler.)
And that's the other one. Java allows hex and octal literals up to (2^32 - 1 = 0xffffffff).