Why do I get an int number is too large where the long is assigned to min and max?
/*
long: The long data type is a 64-bit signed two's complement integer.
It has a minimum value of -9,223,372,036,854,775,808 and a maximum value of 9,223,372,036,854,775,807 (inclusive).
Use this data type when you need a range of values wider than those provided by int.
*/
package Literals;
public class Literal_Long {
public static void main(String[] args) {
long a = 1;
long b = 2;
long min = -9223372036854775808;
long max = 9223372036854775807;//Inclusive
System.out.println(a);
System.out.println(b);
System.out.println(a + b);
System.out.println(min);
System.out.println(max);
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…