aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes something about primitive Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "something about primitive" Watch "something about primitive" New topic
Author

something about primitive

max tan
Greenhorn

Joined: Aug 29, 2002
Posts: 1
what is the different between int and Intenger?
help me thank you!
Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2579

int is a primitive, whereas Integer is a wrapper class that represents primitive int. Often, while dealing with Java collection classes (Vector, HashSet...), Object methods you require to pass them an object as an argument, instead of a primitive. In such cases Wrapper classes come in handy. They also define values such as Double.NaN etc.
You can modify primitive variable value anytime, wrapper class objects on the eother hand, are immutable.
HTH,
- Manish
Barkat Mardhani
Ranch Hand

Joined: Aug 05, 2002
Posts: 787
Originally posted by Manish:

You can modify primitive variable value anytime, wrapper class objects on the eother hand, are immutable.

I thought that only String objects are immutable. Can we not change the primitive stored in an
Integer object?
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
Not unless there's a method to do so. And there isn't one.


Ron Newman - SCJP 1.2 (100%, 7 August 2002)
 
 
subject: something about primitive