BlueJ : Stuck in the Dinosaur Era
Having to use the U. of Kent version of BlueJ. Must be a good reason for that, but, why not get your volunteers to put in basic stuff like autocomplete and... OMG :
java.lang.NullPointerException
with wordMap.clear() (HashMap) why my class DOES have a constructor. But it's :
public WordsInFiles(){
HashMap<String,ArrayList<String>> wordMap = new HashMap<String,ArrayList<String>>();
}
Do you smell a fault Yes, you're declaring a local variable inside the Constructor instead of initializing THE instance variable.
Why the hell can't the compiler or the IDE detect and warn for this?
Thank you : https://stackoverflow.com/questions/45199486/java-hashmap-class-throws-a-nullpointerexception
How about this one? Why can't it tell that the Value is an ArrayList<String> and therefore cannot possibly contain a File object (yes, they don't do a good enough job of cautioning you to use File.getName() to the actual name :)
wordMap = new HashMap<String,ArrayList<String>>();
private void addToMap(File f ){
if(! wordMap.get(word).contains(f) ){
It gets worse. They can't even flag a coding error like this one :
for( int k=1; i < copy.size() ; i++ ){
Comments
Post a Comment