What are Java’s min and max values?

Why is this not Javadoc’d clearly?

Integer.MAX_VALUE =  2147483647
Integer.MIN_VALUE = -2147483648

Long.MAX_VALUE =  9223372036854775807
Long.MIN_VALUE = -9223372036854775808

8 thoughts on “What are Java’s min and max values?

  1. Gary Gregory Post author

    Yes, that’s true, the information is there, buried.

    The implementation of the documentation for constant field values feels like an added-on after thought.

    I have a hard time imagining someone (or people in a meeting) saying: Ok, let’s make this information available, it is indeed useful. But, let’s make them jump through a hyperlink to get there because… what?

    What is worse in this specific case is that the Javadoc for Long.MAX_VALUE does give a value (2^63 – 1) Why one and not the other?

    It’s Math and CS-like to write in powers of 2, yes, but a pain for writing documentation for normal humans.


  2. Caroline McAdams

    How can you declare a really big matrix in Java? Like 3B x 3B entries? Java does not let you define arrays with long, just with int, and int is not enough… any suggestions?


  3. FredashayFredashay

    The trouble is that there is so much information that it is all, in effect, “buried.” That’s an unfortunate result of such a rich and powerful language.

    Suggestions for a 2D array with 3B * 3B entries? Well, other than coupling every computer in the world together to make a single virtual machine to run your JVM, I would recommend using a database to store that (MY SQL or SQL Lite).


  4. Mike Blaszczak

    As presented here, these values are incorrect. For example, “9223372036854775807” is an integer literal, not a long literal. As an integer, it’s much too large. You mean “9223372036854775807L”, which is a long literal and will correctly compile.


  5. sameera

    Have a query i came to know that for int unsigned min val is 0 & max is how much.How do we come to know what are signed & unsigned how can we get maximum & minimum values for all data types in java.Could any one tell me



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s