Samyak Jain Samyak Jain - 5 days ago 5
Java Question

Why cannot I declare my class name as Map?

import java.util.*;

public class Map {

public static void main(String[] args) {

Map map = new HashMap();

map.put("father", "Rob");
System.out.println(map.get("father"));
}
}

Answer

Don't call your main class "Map" - it's clashing with java.util.Map

Comments