Search code examples
javaescapingjava-6

JAVA excape sequence for map key


please help to append " " at the start and end of String.class in the map using escape sequence, i not sure how to add.

static Map Types = new LinkedHashMap();
Types.put(String.class, new StringSerial());

Expected results is "String.class"

thanks


Solution

  • public static void main(String[] args) {
            Map<String, Object> Types = new LinkedHashMap<String, Object>();
            Types.put("\"String.class\"", new Parent());
    
            for (Map.Entry entry : Types.entrySet()) {
                System.out.println(entry.getKey());
            }
        }
    

    Output

    "String.class"