duplicate local variable and variables cannot be resolved

后端 未结 3 1760
庸人自扰
庸人自扰 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:08

    You declared product twice, and you refer to productTotal and salesPersonTotal when they are out of scope. Try changing the second product variable's name (or use the same variable if that's okay with your solution), and try declaring productTotal and salesPersonTotal one scope block up.

提交回复
热议问题