the code is as follows:
package com.helloworld;
public class HelloWorld {
public static void main(String[] args) {
int index; //index
for (int i = 0 ; i < 10 ; iPP) {
if (i == 5 ) {
index = i; //i5index
}
System.out.println("index" + index);
//
//index
}
}
}
The error will disappear only if the initial variable declaration is changed from int index to index index = 0.
but I don"t understand this. I clearly assigned a value in it, why is it wrong?