Results 1 to 5 of 5
Thread: null v/s empty String(" ")
- 11-18-2010, 04:57 AM #1
Member
- Join Date
- Nov 2010
- Posts
- 9
- Rep Power
- 0
- 11-18-2010, 05:01 AM #2
"" contains no characters, but is still a reference to an empty string. null contains no reference data, so basically it doesn't exist at all. Does that make sense or do you want a better explanation?
PS: Have a look at this: http://hanuska.blogspot.com/2006/08/empty-string.html
-
Think of an empty String like an empty egg crate, a String with characters, the same container with eggs, and a null reference -- no egg crate at all.
- 11-18-2010, 05:13 AM #4
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,537
- Rep Power
- 11
We speak loosely about a null string: but there is, literally, no such thing.
myString.equals("") is true when the value of the variable myString is a pointer to a string with no characters in it.
myString.equals(null) is true when the variable myString has a special value that refers to no string whatsoever.
- 11-18-2010, 06:16 AM #5
Similar Threads
-
String output showing "null"
By hayden06f4i in forum New To JavaReplies: 6Last Post: 11-05-2010, 10:21 AM -
string comparison with "=" and ".equal"
By guavajuice in forum New To JavaReplies: 9Last Post: 04-22-2010, 09:01 PM -
JOptionPane.showMessageDialog(null,"Etc Etc"); - What does null actually do?
By markious in forum New To JavaReplies: 2Last Post: 03-19-2010, 05:30 PM -
final String currentWorld = "Java Forums"; String.format("Hello %s", currentWorld);
By mcfrog in forum IntroductionsReplies: 0Last Post: 04-02-2009, 07:02 PM -
the dollar sign "$", prints like any other normal char in java like "a" or "*" ?
By lse123 in forum New To JavaReplies: 1Last Post: 10-20-2008, 07:35 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks