谁能帮我找到这个代码用户名和密码验证的问题。
用户名和密码是预定义的,只是检查这个
package org.test;
import java.util.*;
class User{
public String username;
public String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public void chackLogin(){
Auth a = new Auth();
a.authentication();
}
}
class Auth{
User u;
// username and pass
String auser="admin";
String apass="admin";
public void authentication(){
if((u.username==auser) && (u.password==apass))
{
System.out.println("Login Succseeful sor the user "+" "+auser);
}
else{
System.out.println("incorrect username or password");
}
}
}
public class UserAuth {
public static void main(String[] args) {
//scan Username
Scanner user=new Scanner(System.in);
String usern= user.next();
//scan password
Scanner pass=new Scanner(System.in);
String passw= pass.next();
//object of class USEr
User u =new User();
//set user and pass
u.setUsername(usern);
u.setPassword(passw);
u.chackLogin();
}
}