Hello Members,
What is the largest integer that can be stored in Java?
Thank you!!
Read the documentation.
Java Language Reference section 4.2.1
Any primitive data type has its own wrapper class. The wrapper class of int is Integer which is defined in the package java.lang. Its static attribute MAX_VALUE represents the positive largest value (2147483647)while MIN_VALUE the negative smallest value. In the same way one may obtain the maximum/minimum values for other data types, such as short, long, float, and so on.
import java.lang.Integer;
public class Max {
public static void main(String args[]){
System.out.println(Integer.MAX_VALUE);
System.out.println(Integer.MIN_VALUE);
}
}
Well done tong1 - you just deprived sciprog the chance to learn how to use the Java doc.
primitive integer has range from
-2^31 to 2^31-1
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.