0

hi ..

I want to display an error if the user didn't enter the id or the password in the Text fild.. but nothing happed when I compare it to null .. or to "" .. is there any way to do this? I also tried to compare it with constant .. but it did work as well .. any suggestions?? this is what I have..

if ( (userID.getString() == null ) || (userPW.getString() == null))
		   {
			    System.out.println("Missing required information");
			    doAlarm();

		   }
3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by chaines51
0
if ( (userID.getString().length() == 0 ) || (userPW.getString().length() == 0))

thank u .. I have done what u 've mentioned and its work well now.

but I faced other problem if u could help me..

if the data base could not find the user it should return
string response = "User Not Found"

otherwise it should return the user details .

I tried to check the return value from response but it also not work with me ..

I have written

if (response != "User Not Found")
				 {
					 menu();

				 }
				else
				 {
					 System.out.println("User Not Found,Please Make Sure from Your Login Details");
					 doAlarm();

				 }
0

You should be using String.equals() , or, in this case !String.equals() so, your example would then be:

if(!response.equals("User Not Found");
//blah blah, rest of code

Edited by chaines51: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.