Reference: http://blog.csdn.net/violetjack0808/article/details/50668195
Content:
All along the string of these three empty quite dizzy, just colleague asked me, I also study under.
What you see on someone's blog is this:
IsEmpty ()
The memory space is allocated, the value is empty, is absolute null, is a value (value = null)
""
Allocated memory space, value is empty string, is relative empty, is a value (value = empty string)
Null
is unallocated memory space, no value, is an no value (value does not exist)
However, I was quite dizzy, so I wrote a demo to verify the next ~
@Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main); String a = new string (); String B = ""; String c = null; TestString (a); TestString (b); TestString (c);} private void TestString (String str) {if (str = = null) {LOG.E ("testnull", "null"); } if (Str.isempty ()) {LOG.E ("Testnull", "IsEmpty"); } if (Str.equals (")") {LOG.E ("testnull", "quotation marks"); } log.e ("Testnull", "----------------");}
Because it only plays Android, it writes an Android demo. The effect is the same ~
The log results are:
02-15 14:41:10.655 31875-31875/uding.testanimation E/testnull:isempty
02-15 14:41:10.655 31875-31875/uding.testanimation e/testnull: quotation marks
02-15 14:41:10.655 31875-31875/uding.testanimation e/testnull:----------------
02-15 14:41:10.655 31875-31875/uding.testanimation E/testnull:isempty
02-15 14:41:10.655 31875-31875/uding.testanimation e/testnull: quotation marks
02-15 14:41:10.655 31875-31875/uding.testanimation e/testnull:----------------
02-15 14:41:10.655 31875-31875/uding.testanimation E/testnull:null
Then STR reported null pointer Error ~ Here can be found as if isempty and "" effect is the same drop AH.
And looked at the source of the next IsEmpty:
public Boolean isEmpty () { return count = = 0;}
This means that as long as the text number of string is 0 to return true, and "" The number of text is 0.
Sum up:
Null is the "empty" of unallocated memory space ~
IsEmpty and quotation marks are two "empty" relative to null (that is, they!). = null), and both are allocated memory (as if almost a meaning)
(PS: It is unclear isempty and "" Whether there is any difference, there is a small partner to know that can be commented, thank you ~)
The difference between the IsEmpty method, NULL, and "" of the string class in Java