package se.juneday.trials; import java.util.HashMap; import java.util.Map; import java.util.Collection; import java.util.Set; import se.juneday.domain.Contact; import se.juneday.util.Kreator; public class UseMap { public static void main(String[] args) { int nrContacts = 10; Map contacts = new HashMap<>(); System.out.print("Creating map of Contacts:"); for (int i=0; i contactCollection = contacts.values(); System.out.println("Values"); for (Contact con : contactCollection) { System.out.println(" * " + con); } // Get all the keys from the map System.out.println("Keys"); Set keys = contacts.keySet(); for (String key : keys) { System.out.println(" * " + key); } // Get all the keys and values from the map System.out.println("Entries"); Set> entries = contacts.entrySet(); for (Map.Entry contactEntry : entries) { System.out.println(" * " + contactEntry.getKey() + ":" + contactEntry.getValue()); } // Create Contacts and use integer as key Map contactsIC = new HashMap<>(); System.out.print("Creating map of Contacts:"); for (int i=0; i keysI = contactsIC.keySet(); for (Integer key : keysI) { System.out.println(" * " + key); } } }