Win a copy of Event Streams in Action this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Can Somebody explain me the output (Enthuware)

 
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???
 
author & internet detective
Posts: 39396
763
Eclipse IDE VI Editor Java
  • 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.
 
Bartender
Posts: 1244
86
Hibernate jQuery Eclipse IDE Angular Framework Spring MySQL Database AngularJS Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to CodeRanch!  

You can read Pass by value <--- click here.
 
Ranch Hand
Posts: 49
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 ??
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!