A Java class with the following main:
public static void main(String[] args){
final int n = 3;
String[] array = new String[n];
for (String string : array) {
string = "OK";
}
for (String string : array) {
System.out.println(string);
}
}
produces the output "null, null, null,". Eclipse IDE suggests me that "The value of the local variable ref is not used". Why?
N.B.: I know that I have to iterate the array using this code:
for(int i=0; i<n ;i++)
array[i] = "OK";