user2749343
user2749343

Reputation: 1

java coding in netbeans

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)

Upvotes: 0

Views: 143

Answers (2)

Jigar Joshi
Jigar Joshi

Reputation: 240928

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

jPasswordField1.getPassword().length

Also See

Upvotes: 2

Alex
Alex

Reputation: 11579

Try

jPasswordField1.getPassword().length

getPassword() returns char[]. See docs.

Upvotes: 1

Related Questions