我不明白为什么我收到错误:
GuessingGame.java:15: error: incompatible types
我的代码:
for (numberOfTries=0; numberOfTries = 4; numberOfTries++){
}
required: boolean
found: int
1 error
当numberOfTries类型为int
时,则为4
答案 0 :(得分:0)
你有没有初始化numberOfTries
?
尝试更改此内容:
for (numberOfTries=0; numberOfTries = 4; numberOfTries++){
要:
for (int numberOfTries=0; numberOfTries <= 4; numberOfTries++){