private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    String a,b;
    a=jTextField1.getText();
    b=Arrays.toString(jPasswordField2.getPassword());
    if (a.equals("sam") && b.equals("hi")) {
        JOptionPane.showMessageDialog(null,"Login");
    }
    else{
        JOptionPane.showMessageDialog(null,"Error");
    }
} 
only else part being executed, when using "or" operator if part works. seems to have error in "and" condition.
 
     
    