aspose file tools*
The moose likes Associate Certification (OCAJP 7/8) and the fly likes Java pass by reference Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Associate Certification (OCAJP 7/8)
Bookmark "Java pass by reference " Watch "Java pass by reference " New topic
Author

Java pass by reference

joao ferreira
Greenhorn

Joined: Feb 23, 2009
Posts: 8

//result s=aaa sb=bbbaaabbb
i=5 j=7
null

Why the StringBuilder sb change the value?
E Armitage
Rancher

Joined: Mar 17, 2012
Posts: 892
    
    9
See the code in this post.
Chan Ag
Bartender

Joined: Sep 06, 2012
Posts: 1017
    
  15
Why the StringBuilder sb change the value?


Because sb is pointing to a mutable object. I hope you know why the variable s prints the same value.

[ Edit - I'd suggest to read the entire thread E Armitage is referring to. ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java pass by reference