MapExample { public static <T, U> Map<T, U> createMap(SimpleEntry<T, U>... entries) { return Stream.of(entries).collect(toMap(SimpleEntry::getKey, SimpleEntry::getValue)); }  static Map<T, U> createMap(SimpleEntry<T, U>... entries); static void doSth(Map<T, U> map);  }
@Test public void shouldCreateAHashMapUsingSimpleEntries() throws Exception { Map<String, Integer> nameAndAge = MapExample.createMap(new SimpleEntry<>("shekhar", 32), new SimpleEntry<>("rahul", 33), new SimpleEntry<>("sameer", 33)); assertThat(nameAndAge.size(), equalTo(3)); }