void () { HashMap<String, String> map = new HashMap<>(); for (Integer i1 : Arrays.asList(1, 2, 3, 4)) { String valueOf = String.valueOf(i1); map.putIfAbsent(valueOf.trim(), valueOf); } Object map1 = map; HashMap<String, String> map2 = new HashMap<>(); for (Integer integer : Arrays.asList(1, 2, 3, 4)) { String string = String.valueOf(integer); map2.putIfAbsent(string.trim(), string); } Map<String, String> map3 = new HashMap<>(); for (Integer i : Arrays.asList(1, 2, 3, 4)) { String s = String.valueOf(i); map3.putIfAbsent(s.trim(), s); } }