[BLUEJ-137] Error message on for-each loops seems backwards
This one is sort of Java's fault, but BlueJ really needs to compensate for it.
If you write a for-each loop but put the type of the collection rather than the type of the elements (a common beginner error), your for-loop header looks like this: {noformat} for (ArrayList str : list) {noformat} What BlueJ says about this is: :Incompatible types: found String but expected ArrayList This is exactly backwards from what the student needs to see, because in fact they put ArrayList but needed String.
The reason BlueJ says this is because the raw javac error is: {noformat} StringListProcessor.java:26: incompatible types found : String required: java.util.ArrayList for (ArrayList str : list) { ^ {noformat} That caret (not shown in BlueJ) is the giveaway: having seen the first part of the line, it thinks we want to iterate over a collection of ArrayLists, but then list would need to be an Iterable<ArrayList>, but it's only an Iterable.
Nevertheless, this is really confusing for beginner students. (It was pretty confusing for me until I fired up javac and saw what java was trying to do with it.)
Issue metadata
- Issue type: Task
- Priority: Low
- Fix versions: 3.0.0