This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Java in General and the fly likes Auto Boxing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Auto Boxing" Watch "Auto Boxing" New topic
Author

Auto Boxing

Ramesh Shanmugam
Ranch Hand

Joined: Sep 13, 2004
Posts: 132
what is meant by Auto Boxing technique in Java 1.5 pls explain
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

AutoBoxing means conversion of primitive type to Wrapper type automatically.

For example

Integer i = 12;

Above, int literal 12 is converted to Integer object without any work on the part of the developer. During the pre-tiger days, one had to write

Integer i = new Integer(12);

Using autoboxing, you could just type



Internally however the Integer Object gets created.


Groovy
Ramesh Shanmugam
Ranch Hand

Joined: Sep 13, 2004
Posts: 132
Yes i understood. Thank you
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
How about, if we dont use the Object type anyway?

If we just use primitive types, seems that this object creation can be avoided, isnt it?

Nick


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

If we just use primitive types, seems that this object creation can be avoided, isnt it?


Right but when you are dealing with Collections autoboxing will be used.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Auto Boxing