• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

interesting questions....

 
Ankur kothari
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
isnt String an object...so is String pass by value or pas by reference..and what about StringBuffer


and



 
Ankit Garg
Sheriff
Posts: 9509
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Strings are immutable. So m+="def"; creates a new String object. StringBuffer is mutable, so m.append("abc"); will modify the actual StringBuffer passed to the method...
 
Kedar Sarmalkar
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankur kothari wrote:isnt String an object...so is String pass by value or pas by reference..and what about StringBuffer


and





hey.... both String and StringBuffer are pass-by-value-of-reference.... if thats what you meant to ask.... you are right

refer : htts://javadude.com/articles/passbyvalue.htm
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic