![]() |
Comparing strings....
Hi everyone,
I have a small problem that I just can not work out, regarding comparing user input and pre defined variables. For some reason it just doesn't want to work!! :
btnSubmit.addActionListenerCan someone please tell me what I am doing wrong? Ps System.out's show they are the same!? :confused: |
:
if (enteredUsername.equals("username") && stringToPrint.equals("password"))you can't compare to strings the same way as you do with integers. You have to use equals() |
you can also use equalsIgnoreCase() if you don't want the username and password to be case sensitive
|
Extra Information
For more Information on Interesting methods of the class string go to:
Java API: String ------ Gigabytee |
| All times are GMT -5. The time now is 7:48 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC