• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can Somebody explain me the output (Enthuware)

 
Bharath Rachabattula
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Answer for the above is given as
s=aaa
sb=bbbaaabbb

when there is sb=null in testRefs() it has not affected the value in main(). Can somebody explain me???
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember that Java is pass by value. This means that the changes to "str" are lost after the method. sb.append() however is a method call so the value of sb changes. Then when sb is set to null, that's only the method's parameter reference. The main method still has a reference to the object.
 
Ganesh Patekar
Bartender
Posts: 694
23
Eclipse IDE Hibernate Java jQuery MySQL Database Netbeans IDE Oracle Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to CodeRanch!  

You can read Pass by value <--- click here.
 
yogesh doshi
Ranch Hand
Posts: 33
Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can some one help me with what are the topics need to be covered under lamda for OCA8 certification ??
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic