public void TheBank() {
Scanner Sc = new Scanner(System.in);
System.out.println("Please Enter your Username and Password");
MemoryStorage();// Stores the Username and Password in the system.
VariableCompare();// Compares the Username and Password to see if they match or do not
}
private void MemoryStorage(){// this should just be here to store the variables username and password
Scanner Sc = new Scanner(System.in);
String username = Sc.nextLine();
String password = Sc.nextLine();
}
private void VariableCompare() {// this should compare to see if they match or dont and print the results
if (username.equals (password){
System.out.println("Please try again your Username and Password cannot be the same");
} else {
System.out.println (" Your username is:" + username);
System.out.println(" Your password is:" + password);
}
}
}
我的問題是身體(MemoryStorage)來自私人機構的變量,我想它來保存用戶名和密碼,從而使其他機構可以使用它與藏漢他們的計算進行。目前,變量的用戶名和密碼不被接受到其他機構,我想知道如何讓這兩個變量可供所有機構使用。如何訪問在java中
然後將用戶名和密碼設置爲實例變量。 – Rajesh 2015-04-06 11:42:18