File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is the difference between "" and " "?

 
Guoqiao Sun
Ranch Hand
Posts: 317
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, what is the difference between "" and " "?
regards,
Guoqiao
 
Aakanksha
Ranch Hand
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i guess, "" is equivalent to null whereas " " represents a white-space character.
correct me if i am wrong.
/Aakanksha
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. "" does not equal null. "" represents an empty String but not a null.
Try comparing these two Strings:
s1 = "";
s2 = null;
System.out.println(s2.equals(s1));
System.out.println(s1.equals(s2));
The first test will answer false. The second test will throw a null pointer exception.
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"" is an empty String, whereas " " is a non-empty blankspace character String
-- Sandeep
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic