This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Integer and int  RSS feed

 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is that true, that Integer can only handles value between −32.768 till 32.767 and unsigned till 65.535.

And int can handle values till 4.294.967.295 (unsigned) ?
 
Albareto McKenzie
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nimo

Try this:

System.out.println(Integer.MAX_VALUE);
System.out.println(Integer.MIN_VALUE);

What do you get?

For your other question about int type:

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html



 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16007
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java does not have unsigned integer types (apart from char) like C or C++ has.

And what you say about Integer is not correct; class Integer is just a wrapper class for int. See The Numbers Classes in Sun's Java Tutorials.

An int in Java is 32 bits and is encoded in [url=http://en.wikipedia.org/wiki/Two%27s_complement]two's complement[/url] format, so it can hold values from -2^31 to 2^31 - 1.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!