我想爲某個用戶使用一個特定的密碼登錄多個用戶。我知道String user = new String("User")
擁有用戶登錄名,但我希望能夠添加多個名稱和密碼。我也想知道它是否可能只有特定的用戶才能使用某些密碼。多登錄用戶和密碼Java
P.S.我也是初學者,請在我身上輕鬆點。
import java.io.*;
public class Login {
public static void main(String[] args) throws IOException {
String greeting = "Hello";
String username;
String password;
String user = new String("User");
String pass = new String("Password");
BufferedReader br = new BufferedReader(
new InputStreamReader(System.in));
System.out.println("*** Welcome to the program ***\n");
System.out.println(greeting);
System.out.println("Please type your username :");
username = br.readLine();
System.out.println("Please type your password :");
password = br.readLine();
if (username.equals(user))
System.out.println("They are the same");
else
System.out.println("That is wrong");
System.exit(0);
if (password.equals(pass))
System.out.println("They are the same");
else
System.out.println("That is wrong");
System.exit(0);
}
}
假設這是作業作業,請使用地圖。假設這是一個真正的安全系統,請使用數據庫並加密密碼。 – Compass
你的問題是什麼? –
我希望能夠使用多個用戶和密碼。 –