foreach - Java - can't change int value inside for-each loop -


this question looks hilariously obvious, can't see fault... i'm declaring int variable inside for-each loop , looks can't modify it.

for(string tmp : list) {         int = 0;         system.out.println("i = " + i);         i++; } 

list linkedlist not empty , exists somewhere in code. output is:

i = 0 = 0 = 0 

is possible modify value of int inside such loop? thanks.

with each loop, create new i variable, 1 unrelated previous ones previous iterations of loop. solution: declare above loop.

int = 0; for(string tmp : list) {         system.out.println("i = " + i);         i++; } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -