Q:

Casting and Retrieving a Key Set of a Map

I have a method-
private void mapSomething(Class<?> dataType){

   if(dataType.isInstance(Map.class)){
      // How do I get the key set of the map
   }
}

Method is called like-
mapSomething(someHashMap.getClass()); // Hash Map

How do I get the key set of the map inside the method?

A:

You're not actually passing in an instance of Map (just its class data).  If you can change your method signature to something like this it'd be easy enough:
private void mapSomething(Object data){
    if(data instanceof Map){
        ((Map)data).keySet()
    }
}

