所以我知道我的問題,但我似乎無法找出一種方法來解決它,我想要做的是在用戶提供他們優先使用的用戶名後,我想打印輸入旁邊的phoneNumber,然後問題I正在跑進這裏。如何在每個參數輸入方法後打印?
我會得到用戶輸入,
用戶名:電話號碼:那麼現在,他們可以輸入
相反,我要的是這樣的:
用戶名:輸入從方法的參數。 ....
電話號碼:同樣的事情上面
更新版本:
這是錯誤我得到的輸出提示輸入用戶名或電話號碼後
用戶名無法解析爲一個變量
public void createCustomer(String userName){
System.out.print("Enter username: ");
this.user = input.nextLine();
this.user = userName;
this.password = password;
this.address = address;
this.phoneNum = phoneNum;
this.email = email;
}
public static void main (String args[]){
CustomerUI customer = new CustomerUI();
Scanner input = new Scanner(System.in);
if(shouldCreate()== true){
customer.createCustomer(userName);
}
您需要保存在本地變量輸入,然後通過那些方法以後。這樣你可以插入你想要的任何東西來獲得輸入和調用方法。 –
是的,我認爲這是有道理的,謝謝你的確認。 –