Clay Dagler
Posts: 21
Nickname: cdagler
Registered: Jul, 2003
|
|
Re: String problem
|
Posted: Oct 17, 2003 10:33 AM
|
|
> Hi, > > I am trying to get value from JTextField.I stored that > string into a string named textname.My problem is if i > didn't enter anything in the JtextField, the string > textname is not having any thing...That's even a null > value... > > ie. String textname = txt.getText(); > System.out.println("Name is " + textname); > > It gives output as follows: > > Name is > > > > > I am checking some condition if it is null like that...for > that i gave > > if (textname == null) > { > System.out.println(" Please enter something"); > } > > > But it's not working...I am surprised why it's not > working...Is that am i doing wrong???? > Give me solution please ....it's urgent
Try
if (textname == "") { System.out.println(" Please enter something"); }
I am 95% sure that this will work.
Clay
|
|