为什么我用户名、密码 正确输入了admin和123,逻辑上判断是false?
button1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String str=textField.getText(); char ch[]=passwordField.getPassword(); String pass=new String(ch); /* boolean bool1= str=="admin"; boolean bool2= pass=="123"; System.out.println(bool1); System.out.println(bool2); */ if (str=="admin" || pass=="123" ) { mainpage p=new mainpage(); dispose(); } else { JOptionPane.showMessageDialog(null, "用户名或密码错误!","登陆失败!",JOptionPane.PLAIN_MESSAGE); } } });
守着星空守着你
蓝山帝景
相关分类