Java9: Collections Factory Methods

Photo by Aviv Rachmadian on Unsplash
Set<String> set = Set.of("A","B","C");
System.out.println(set);

List<String> list=List.of("A","B","C");
System.out.println(list);

Map<String,String> map=Map.of("A","Apple","B","Boy","C","Cat");
System.out.println(map);

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nuwan Zen

Nuwan Zen

Sometimes A software Engineer, sometimes a support engineer, sometimes a devops engineer, sometimes a cloud engineer :D That’s how the this life goes!