Hi Friendz, can anybody explain these mentioned line of code. where i m wrong... 1. String a="one"; String b=a.concat(a); //result is oneone if (a=="one") //true ok i m satisfied coz same string pool if (b=="oneone") //false what is that even both b and "oneone" same string pool
2.String c=" one "; if (c.trim()=="one") //false ??? anybody explain if (c.trim()==c.trim()) //still false what is that ??? plz give me detail both above questions. thanx Aftab
1. concat() returns a "new" string which is not in the string pool although you can intern it into the pool. 2. trim() also returns a new string unless there is nothing to trim in which case, it returns the original string. In fact, every time you call trim (as you did below), it always returns a "new"