java coding in netbeans

181 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 best solutions below

0
On

Try

jPasswordField1.getPassword().length

getPassword() returns char[]. See docs.

1
On

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

jPasswordField1.getPassword().length

Also See