Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String methods....

 
Nidhi Juneja
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks...look at the following code...has put my concepts in doubt..

I don't understand why cond 2 returns false while cond 4 returns true. Can anyone put more light on this topic
[ Jess added UBB [CODE] tags to preserve whitespace ]
[ October 09, 2002: Message edited by: Jessica Sant ]
 
John McAlroy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both, trim() and toUpperString() create a new string object ONLY IF there a change is required in the original string otherwise, same object is returned. So, 2 returns false while 4 returns true.
 
Nidhi Juneja
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks John but is it for only these 2 methods or for all the string class methods.....
 
Nidhi Juneja
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried a number of questions and i think it is a basic rule for all methods ....correct me if i am wrong
 
sun par
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In String class this holds for substring also if the whole string is returned as a result of the operation
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just take a look at the API. It tells the full story.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic