I get an ERROR (whatever my var is ) cannot be resolved to a variable | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I get an ERROR (whatever my var is ) cannot be resolved to a variable

Error

15th Aug 2016, 10:45 PM
Chuckinator
8 Answers
0
Maybe, it is about the scope of variable.
15th Aug 2016, 10:52 PM
WPimpong
WPimpong - avatar
0
Meaning?
15th Aug 2016, 10:52 PM
Chuckinator
0
Mine involves arrays both of the example ones said that error
15th Aug 2016, 11:04 PM
Chuckinator
0
Could you copy and paste your code for us please?
16th Aug 2016, 12:12 AM
James
James - avatar
0
if(1==0) { String myVar = "a"; System.out.println(myVar); }
16th Aug 2016, 3:53 AM
Ravi Kumar
Ravi Kumar - avatar
0
i think its ur if condition which is suspicious !! try ( 1!=0)
12th Sep 2016, 10:35 PM
Bhushan Gaikwad
Bhushan Gaikwad - avatar
0
your if condition is false, so next line is not executed. That's why myVar remains not declared. either correct your if condition or put a semicolon after it.
8th Nov 2016, 2:58 PM
vikas kawatra
vikas kawatra - avatar
- 1
E.g. if(1==0) String myVar = "a"; System.out.println(myVar); Error myVar cannot be resolved.
15th Aug 2016, 10:59 PM
WPimpong
WPimpong - avatar