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 pass value or pass reference Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "pass value or pass reference" Watch "pass value or pass reference" New topic
Author

pass value or pass reference

Jingxian Zhou
Greenhorn

Joined: Jun 22, 2010
Posts: 28

Why is pass value,other is pass reference?


SCJP6(310-065) with 96%, SCWCD (310-083) with 89%, SCBCD 5 (310-091) with 98%
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

I don't see any method calls. Why are you asking about pass by value or pass by reference ?


[My Blog]
All roads lead to JavaRanch
Jingxian Zhou
Greenhorn

Joined: Jun 22, 2010
Posts: 28
Christophe Verré wrote:I don't see any method calls. Why are you asking about pass by value or pass by reference ?

Thanks for your answer.

Sorry,my question is not correctly.I have a confused that the result is false and true.Why ?
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

Jingxian Zhou wrote:
Sorry,my question is not correctly.I have a confused that the result is false and true.Why ?


This is related to object mutability. Wrapper Class Object are immutable, and StringBuilder object are mutable!


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Jingxian Zhou
Greenhorn

Joined: Jun 22, 2010
Posts: 28
Abimaran Kugathasan wrote:
Jingxian Zhou wrote:
Sorry,my question is not correctly.I have a confused that the result is false and true.Why ?


This is related to object mutability. Wrapper Class Object are immutable, and StringBuilder object are mutable!


Thanks Abimaran Kugathasan.

Can you tell me the reference ?
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

Jingxian Zhou wrote:
Can you tell me the reference ?


Have Googling! You'll find a lot.
Shanky Sohar
Ranch Hand

Joined: Mar 17, 2010
Posts: 1051

This is related to object mutability. Wrapper Class Object are immutable, and StringBuilder object are mutable!


we know that string buffer object are mutable.......that means
sb1.append("5"); will add 5 to sb1........
and sb2 is pointing to sb1.......so it will return to............

but if the wrapper class objects are immutable that means..........."x==y" must be identical........but it is returing False......why.......

SCJP6.0,My blog Ranchers from Delhi
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

phil sohan wrote:
but if the wrapper class objects are immutable that means..........."x==y" must be identical........but it is returing False......why.......


What happen when you do this operation?


There will be a new Integer object will be created with the value(the incremented value) and x will be assigned to the newly created object.

Try the below coding.


You'll get it!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: pass value or pass reference