fork download
  1. import java.util.ArrayList;
  2. import java.util.HashMap;
  3. import java.util.List;
  4. import java.util.Map;
  5. import java.util.Map.Entry;
  6.  
  7.  
  8. public class Main {
  9.  
  10. public static void main(String[] args) {
  11.  
  12. Map<String, Integer> map = new HashMap<>();
  13.  
  14. map.put("hello", 1);
  15. map.put("world", 2);
  16.  
  17. List<Entry<String, Integer>> list = new ArrayList<>(map.entrySet());
  18.  
  19. System.out.println("list size: " + list.size());
  20.  
  21. System.out.println("list[0].key: " + list.get(0).getKey());
  22. System.out.println("list[0].value: " + list.get(0).getValue());
  23.  
  24. }
  25.  
  26. }
  27.  
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
list size: 2
list[0].key: hello
list[0].value: 1