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();

		   }
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();

				 }

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 7 Years Ago by chaines51: n/a

This article has been dead for over six months. Start a new discussion instead.