Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

for loop : Cannot be resolved to a variable

Tags:

java

I was wondering why I had this error when I tried to do this :

Map<Integer, List<String>> map = (Map<Integer, List<String>>) parameters;

for(Integer i : map.keySet()) {
    tableFiles.setWidget(row, 0, addPanelFile(String.valueOf(i)));
    row++;
    for(map.get(i)) {

    }
}

Why can't i be resolved to a variable ?

like image 784
l0r3nz4cc10 Avatar asked Feb 05 '26 08:02

l0r3nz4cc10


1 Answers

The for-loop is malformed.

Change

for(((Map<Integer, List<String>>) parameters).get(i)) {

}

into

for(SomeType someVar : ((Map<Integer, List<String>>) parameters).get(i)) {

}

and you should get a better error-message.

like image 200
aioobe Avatar answered Feb 07 '26 20:02

aioobe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!