I am getting the below error for HashMap in the Java code.
Error - "The type HashMap is not generic; it cannot be parameterized with arguments <>"
package com.example.map;
import java.util.Map;
import java.util.HashMap;
public class HashMap {
public static void main(String[] args) {
// compilation error here vvvvvvv
Map<Integer, String> mapHttpErrors = new HashMap<>();
mapHttpErrors.put(200, "OK");
mapHttpErrors.put(303, "See Other");
mapHttpErrors.put(404, "Not Found");
mapHttpErrors.put(500, "Internal Server Error");
System.out.println(mapHttpErrors);
}
}
ArrayList-- you named your class the same name as the type you're attempting to use.