import java.util.*; public class OutputMaps // demonstrate the 3 types of maps, inserting items with random keys { public static void main(String[] args) { // our three maps HashMap map1=new HashMap<>(); // HashMap places items in order by hash function LinkedHashMap map2=new LinkedHashMap<>(); // LinkedHashMap places items in ascending order by value TreeMap map3=new TreeMap<>(); // TreeMap places items in ascending order by key Random g=new Random(); int value; // to store the random number for(int i=0;i<10;i++) { value=g.nextInt(100); map1.put(new Integer(value), new Integer(i)); // hash order map2.put(new Integer(value), new Integer(i)); // order by i map3.put(new Integer(value), new Integer(i)); // order by value } System.out.println(map1); // output the maps to demonstrate System.out.println(map2); System.out.println(map3); } } /* sample output {68=9, 2=3, 54=6, 96=5, 24=4, 41=2, 56=0, 89=1, 31=8} {56=0, 89=1, 41=2, 2=3, 24=4, 96=5, 54=6, 31=8, 68=9} {2=3, 24=4, 31=8, 41=2, 54=6, 56=0, 68=9, 89=1, 96=5} */