• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

regarding strings

 
ganne suresh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
string s="hai";
string s=s+"hello";

here s contains "haihello" .
actually string is immutable,but how here "haihello" is coming
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

First off.I should say this qstn is NOT relavent to this
session. Having said that, to ans your qstn, the second
line of your code will return a new reference to s and
the previous will be lost.
In future, pl. post such qstns in the Java
Beginner/Intermediate forum and not here.
ps: This thread can be closed and moved to the
Beginners forum.
Regds.
- satya
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ganne,
Since it is good to have things in an organaized way, we try to keep the related threads in one forum. please visit Java Beginners forum.
regds
maha anna
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic