Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String

 
Rishi Wright
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi 'all
public class Test {
public static void main (String args []) {
String s="AB";
System.out.println(s.startsWith("",2));//1
System.out.println(s.startsWith(" ",2));/2
System.out.println(s.startsWith("",3));//3
}
}
at line //1 it prints true where as at //2 it prints false.Is there any difference between ""&" "???
thnx
rishi
 
Vikram Reddy
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(" ") represents a blank space (string of length 1) and ("") is nothing (string of length 0).
HTH.
--Vikram
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic