Author
what is the difference between "" and " "?
Guoqiao Sun
Ranch Hand
Joined: Jul 18, 2001
Posts: 317
Hi, what is the difference between "" and " "? regards, Guoqiao
Guoqiao Sun<br />SCJP2 SCWCD2<br />Creator of <a href="http://www.jiris.com/" target="_blank" rel="nofollow">www.jiris.com</a>, Java resource, mock exam, forum
Aakanksha
Ranch Hand
Joined: Jul 17, 2001
Posts: 60
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
Joined: May 05, 2000
Posts: 13974
posted Jul 27, 2001 10:49:00
0
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.
Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Desai Sandeep
Ranch Hand
Joined: Apr 02, 2001
Posts: 1157
"" is an empty String, whereas " " is a non-empty blankspace character String -- Sandeep
<b>Sandeep</b> <br /> <br /><b>Sun Certified Programmer for Java 2 Platform</b><br /> <br /><b>Oracle Certified Solution Developer - JDeveloper</b><br /><b>-- Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java </b><br /><b>-- Object-Oriented Analysis and Design with UML</b><br /> <br /><b>Oracle Certified Enterprise Developer - Oracle Internet Platform</b><br /><b>-- Enterprise Connectivity with J2EE </b><br /><b>-- Enterprise Development on the Oracle Internet Platform </b>
subject: what is the difference between "" and " "?