aspose file tools*
The moose likes Beginning Java and the fly likes Integer and int Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Integer and int" Watch "Integer and int" New topic
Author

Integer and int

nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
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

Joined: Apr 08, 2009
Posts: 298
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
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14269
    
  21

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's_complement]two's complement[/url] format, so it can hold values from -2^31 to 2^31 - 1.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Integer and int