for (String inList : myList) {
System.out.println(inList);
}
Error
ClassB.java:11: incompatible types
found : ClassA
required: java.lang.String
for (String inList : myList) { ...
Well as you can see in the error message it says
found ClassA required
String for (String inList : myList).
So the code
state that in the List called myList each element will be a String
But this is not true because it is declared as a ArrayList of ClassA :
.
In conclusion the solution is to do :
as the compiler told you.