Reputation: 2132
I have been reading this: http://docs.oracle.com/javase/tutorial/uiswing/components/passwordfield.html but I have a problem. I got a simple method which checks if my JTextField
s and my JPasswordField
s are empty or not
So I have this one:
private boolean addCustomerCheckValidInfo()
{
for(JPasswordField pf : newCustomerPasswordFields)
{
if (pf.getPassword().length == 0);
{
System.out.println("Password length " + pf.getPassword().length);
return false;
}
}
return true;
}
The same returns false and writes in the console:
Password length 3
As I have read on the oracle guide, passfield.getPassword().length should return the length (as it does in the system.print.out), but why does it fail at if it's equals to 0 when it's > 0?
Upvotes: 0
Views: 209
Reputation: 324147
if (pf.getPassword().length == 0);
You have a typo. You added a ";" at the end of the if statement. So you really created an empty if statement. Get rid of the ";".
Upvotes: 2