我對Java編程還很新,我正在嘗試構建一個文本遊戲來幫助我學習。我遇到問題時將一個變量傳遞給我,幫助我測試規格。如何在java中傳輸變量
String a = user.next();
if(a.equals("warrior")){
System.out.println("You start to feel stronger, feels like you could run through a brick wall and keep on going without a scrath on you.\n" +
"Of course you might want to wait on that for awhile.\n" +
"********************************************************\n*\t\tAchievement got: Dumb as a rock!\t\t\t\t\t\t *\n********************************************************");
String specW = ("warrior");
comW (warrior);
}
public static void comW (warrior){
System.out.println("Testing1");
}
是任何人能幫助我弄清楚爲什麼我一直有錯誤?
'公共靜態無效comW(勇士){'你需要給一個類型爲'warrior' – litelite
意味着什麼litelite是你應該String類型添加到方法的簽名:'公共靜態無效comW(字符串戰士)' – alfasin
你似乎需要閱讀一些Tutos,有很多錯誤 – azro