• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Material for Wrapper class

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
Please give me site or any online material from which i can understand Wrapper class boxing,un-boxing with ==,!= and equals concept.
 
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Manisha,
I thought K&B covers it pretty well. Are you asking for something more than that?
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Manisha,

Try this link:
Wrapper Class
 
manisha makwana
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Thanks for the reply actually i am not getting that when we say
Integer i1 = 10; At this time what happen is first it makes an object of Integer class and assign value 10 to it ok??correct me if i am wrong.

case1 Integer i1 = 10;
Integer i2 = 10;
i1==i2 // it gives true
at this time it check for the value why?though i1 and i2 are object
and when i say
case 2 Integer i1 = new Integer(10);
Integer i2 = new Integer(10);
i1==i2 //it gives false

i guess internally in case 1 the objcet gets created please help me for this topic
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well in case1 Integer i1=10 creates an Integer instance and places it in the pool the statement Integer i2=10 does not create an seperate object rather the reference i2 now points to the Integer object i1 which is placed on the pool ,now matter how many times we execute the statement like Integer <reference name> = 10 the result of their execution will be that each reference will point to the instance placed on the pool, so when we use the == operator in case 1 it will return true as i1 and i2 hold references of the same instance (which is placed on the pool)

But when we use the keyword "new" seperate instances are created with each instance placed on the heap rather than on the pool as a result i1 and i2 now hold reference of two different Integer instances which have the same value 10. so when we use the == operator it will return false as i1 and i2 are two entirely different objects
 
manisha makwana
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Thanks for the answer.
 
reply
    Bookmark Topic Watch Topic
  • New Topic