Main.java獲得價值
public static void main(String[] args) {
String username ="";
String password = "";
Class_b b = new Class_b();
b.login("username","password");
}
Class_b.java
public String login(String user, String pass) {
String username = "admin";
String password = "password";
return username+" "+password;
}
我想從Class_b
得到username
和password
值,並將其存儲到字符串變量username
和password
在Main.java中。
你顯然是將用戶名和密碼傳入登錄函數FROM main,爲什麼你需要將它返回給main? – redunderthebed