嘿,我是一個新的java程序員,並嘗試製作密碼系統。我希望有人查看代碼並給我一些建議。該代碼也有一個錯誤,我不能弄清楚,所以我需要有人告訴我我的錯誤詳細,所以我不會再犯這個錯誤。謝謝!密碼系統錯誤
package Main;
import java.util.Scanner;
public class ProgramRunner {
public static void main(String [] args){
Scanner imput = new Scanner(System.in);
umNoName lol = new umNoName();
//password
String password = "pass";
lol.GetPassword(password);
}
}
package Main;
import java.util.Scanner;
public class umNoName {
public static String password = "pass";
public String Name;
public void simpleMessage(String Name){
System.out.println("Hello " + Name);
}
public void GetPassword(String password){
Scanner imput = new Scanner(System.in);
System.out.println("Password: ");
String Password = imput.nextLine();
if(Password == password){
simpleMessage(Name);
}else{
System.out.print("Password is incorrect!");
System.exit(0);
}
}
}
「該代碼也有一個錯誤,我無法弄清楚」 - 什麼是錯誤? – scottysmalls