Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Interesting string methods  RSS feed

 
Sarma Lolla
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Except the last two every thing else prints true.
[CODE]
public static void main(String [] args) {
System.out.println("String".substring(0)=="String");
System.out.println("String".substring(0,6)=="String");
System.out.println("String".replace('t','t')=="String");
System.out.println("String".replace('T','t')=="String");
System.out.println("String".toString()=="String");
System.out.println("String".replace('t','T')=="String".replace('t','T'));
System.out.println(" String ".toString()=="String");
}
[CODE]
 
Jasper Vader
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i guess cos the last two are the only two in which an actual change takes place? (t goes to T, the white space gets removed)...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!