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