Why initialization of new Long Wrapper with int literal is valid?

Viewed 890

Looking at the Java Doc for Long, it only has two constructors:

    1) primitive long as param --> new Long(10L);  
    2) String as param --> new Long("23");

But this works new Long(23);

But if the literal is more than the int MAX VALUE (2147483647), the L suffix becomes mandatory so this: ( new Long(2147483648) will now require an L after the value

However: new Long(Integer.MAX_VALUE + 1) is OK

Who can explain this?

4 Answers
Related