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
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: 13881
    
  10

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 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Integer and int
 
Similar Threads
Literals
Signed and Unsigned int
so confused, help
Q from examulator.com
unsigned integer