I'm having a hard time finding the error in a logic that I use for to traverse an arraylist.
List<Caneta> canetas = new ArrayList<>();
canetas.add(c1);
canetas.add(c2);
System.out.print(Arrays.toString(canetas.toArray()));
for (Caneta caneta : canetas) {
int x = 0;
System.out.printf(canetas.get(x).getModelo());
x++;
}
The sout returns the same answer, as if x had not autoincrementado, could someone explain the problem? Thankful.