Map<String,String> paramMap = new HashMap<>();
I tried to use HashMap when I read a list of numbers from csv and want to proceed to the next process only for unique ones, but ...
Map<String, String> paramMap = null; while((record = reader.readNext()) != null){ if(paramMap.get(record[0]) != null { continue; } paramMap.put(record[0],record[0]); Next processing }
Then, an error occurs in nullpointer.exception in the part of paramMap.get It's easy to know what to do
Map<String, String> paramMap = null;
With this, pramMap has not been initialized, and if you call it, a null reference will occur. Here
Map<String,String> paramMap = new HashMap<>();
Then it works fine
I would be grateful if you could tell me if there is another good way to retrieve unique records ^ _ ^
Recommended Posts