assertEquals( new Long(42681241600) , new Long(42681241600) );
I am try to check two long numbers but when i try to compile this i get
integer number too large: 42681241600
error. Documentation shows there is a Long,Long assertEquals method but it is not called.
You want:
assertEquals(42681241600L, 42681241600L);
Your code was calling assertEquals(Object, Object). You also needed to append the 'L' character at the end of your numbers, to tell the Java compiler that the number should be compiled as a long instead of an int.
42681241600 is interpreted as an int literal, which it is too large to be. Append an 'L' to make it a long literal.
If you want to get all technical, you can look up §3.10.1 of the JLS:
An integer literal is of type
longif it is suffixed with an ASCII letterLorl(ell); otherwise it is of typeint(§4.2.1). The suffixLis preferred, because the letterl(ell) is often hard to distinguish from the digit1(one).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With