Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interesting string methods

 
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)...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic