java coding in netbeans

143 views Asked by At

The following code written in netbeans it shows error as cannot find length() method and invert if.im new to netbeans. please correct my code.thanks in advance.

 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
       if(jTextField1.getText().trim().length() == 0 && jPasswordField1.getPassword().length() == 0)
2

There are 2 answers

0
Alex On

Try

jPasswordField1.getPassword().length

getPassword() returns char[]. See docs.

1
Jigar Joshi On

getPassword() returns char[] so use .length field

jPasswordField1.getPassword().length

Also See