File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Material for Wrapper class 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 "Material for Wrapper class" Watch "Material for Wrapper class" New topic
Author

Material for Wrapper class

manisha makwana
Ranch Hand

Joined: Sep 14, 2007
Posts: 37
Hello,
Please give me site or any online material from which i can understand Wrapper class boxing,un-boxing with ==,!= and equals concept.
Sekhar Kadiyala
Ranch Hand

Joined: Feb 17, 2004
Posts: 170
Hey Manisha,
I thought K&B covers it pretty well. Are you asking for something more than that?


PMP CSQA SCJP SCWCD SCBCD INS 21 INS 23
Saurabh Verma
Ranch Hand

Joined: Aug 13, 2007
Posts: 38
Hi Manisha,

Try this link:
Wrapper Class
manisha makwana
Ranch Hand

Joined: Sep 14, 2007
Posts: 37
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
dipayan chatterjee
Ranch Hand

Joined: Oct 03, 2007
Posts: 47
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


SCJP1.4 , gearing up for SCWCD 5
manisha makwana
Ranch Hand

Joined: Sep 14, 2007
Posts: 37
Hey Thanks for the answer.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Material for Wrapper class