why there is an error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why there is an error

static int removeElement(int[] nums, int val) { String c = "-122"; int b = 9; for (int b = 0;b<122;b++){} } question: why the int b in for block can not coexist with int b in method removeElement why int b in for block can not shadow the int b of the method body.

9th May 2021, 12:20 PM
Zhengrong Yan
Zhengrong Yan - avatar
1 Answer
+ 1
Hi! you declare the variable b twice. you can't do that. and why do you need a c variable with a string value inside?
9th May 2021, 12:48 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar