JOptionPane.showInputDialog question?

String a = JOptionPane.showInputDialog("Enter something");

if ( a ==null)

dothis

elseif ( a.equals("\u2422"))//well it's not the blank character...

dothis

else

dothis

I just want to catch if nothing is entered and loop the prompt, it's proven to be more difficult than I thought... When the user doesn't input anything and just presses "OK", what value is assigned to String a?

[882 byte] By [rugaea] at [2007-11-27 9:00:41]
# 1
The empty String "", I suppose.
java_knighta at 2007-7-12 21:29:39 > top of Java-index,Java Essentials,New To Java...
# 2
"" is the same as null is it not ?
rugaea at 2007-7-12 21:29:39 > top of Java-index,Java Essentials,New To Java...
# 3
Not, "" is an empty string which is what will be getting passed
ita6cgra at 2007-7-12 21:29:39 > top of Java-index,Java Essentials,New To Java...
# 4
> "" is the same as null is it not ?Try invoking .getChars() on both "" and null. Let us know what happens
georgemca at 2007-7-12 21:29:39 > top of Java-index,Java Essentials,New To Java...
# 5
Ok, I got the point now null != "", .getChars() gave me a blank for "" (was expecting exception) and null pointer exception for null string (as expected);So would a.length() == 0 be a good comparison to reloop the prompt input dialog?Message was edited by: rugae
rugaea at 2007-7-12 21:29:39 > top of Java-index,Java Essentials,New To Java...
# 6
Indeed it would or alternatively a.equals("");
ita6cgra at 2007-7-12 21:29:39 > top of Java-index,Java Essentials,New To Java...
# 7
> Indeed it would or alternatively> > a.equals(""); or indeed "".equals(a); // no nasty NPE here
georgemca at 2007-7-12 21:29:39 > top of Java-index,Java Essentials,New To Java...
# 8
Ah you are a cunning one! lol
ita6cgra at 2007-7-12 21:29:39 > top of Java-index,Java Essentials,New To Java...
# 9
Thanks both ita6cgr and georgemc for the explanations and georgemc for the little exercise that corrected my misconceptions.cheers
rugaea at 2007-7-12 21:29:39 > top of Java-index,Java Essentials,New To Java...