Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Auto Boxing

 
Ramesh Shanmugam
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is meant by Auto Boxing technique in Java 1.5 pls explain
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ramesh Shanmugam
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes i understood. Thank you
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic