Actually my system gives Long.MAX_VALUE as 9223372036854775807
But when I write my program like this,
package hex;
/**
*
* @author Ravi
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
long x = 9223372036854775807;
System.out.println(x);
}
}
I am getting compile time error. Can anyone explain the reason?
With no suffix, it’s an int constant (and it overflows), not a long constant. Stick an
Lon the end.