duplicate local variable and variables cannot be resolved

后端 未结 3 1764
庸人自扰
庸人自扰 2021-01-27 02:53

I\'m being given three different errors in my java code, any help?

Error one: Duplicate local variable product.

int product = input.nextInt();
3条回答
  •  一个人的身影
    2021-01-27 03:22

    Any variables created inside of a loop are local to the loop. This means that once you exit the loop, the variable can no longer be accessed. If you want to use the variable after you left the loop, then you have to declare it before beforehand in the outer loop or method scope.

提交回复
热议问题