我的問題是,當我運行代碼if語句運行,但然後繞過for循環。我是新手,這是第一篇文章。歡迎所有幫助。爲什麼在我的if語句中沒有運行for循環? Java
if (tMenuChoice == 1)
{
System.out.println("How many teams are there going to be?");
int tNumberOfTeams = tKeyboard.nextInt();
// This is where the code stops running. The for loop is not read but bypassed.
for (int i = 1; i == tNumberOfTeams;i++)
{
System.out.println("Team " + i + "'s name?");
String tNameOfTeam = tKeyboard.nextLine();
String [] tTeamArray = new String[i];
}
}
感謝
請檢閱'for'循環的工作方式:http://docs.oracle.com/javase/tutorial/java/nutsandbolts/for.html。 –
同意。你知道這是for循環是錯誤的,所以你應該研究教程或你的書的循環,你會馬上看到你的錯誤。 –