I changed the list reference and point it to the whole new list while iterating over it but it still prints the old value.
This may seems incorrect , why anyone wants to change the list itself reference itself while iterating over it but iteration is going on and some another functionality changes the reference itself or create new object and assign it to the original list.
for (String s : lst) {
System.out.println("list is:"+lst);
System.out.println(s);
lst = lst1;
}
This still prints the old list after one iteration.