Creating a method to check if a value exists in a generic HashMap in Java?

I was trying to create a generic method for checking if an item exists within a HashMap. Simple enough concept, but Java does not like what I'm trying to do. Is this even possible? This was my attempt.

private static boolean inMap(String file, HashMap map) {

for (Map.Entry entry : map.entrySet()) {

if (entry.getKey().equals(file)) return true;

}

return false;

}

This is called in the following section of code:

private static Map files = new HashMap();

private static Map images = new HashMap();

private static Map textures = new HashMap();

private static Map models =...

Read More »

By: StackOverFlow - Wednesday, 7 November

Related Posts