fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. ArrayList<HashMap<String, String>> AL_route_bus_collection_a = new ArrayList<HashMap<String,String>>();
  13.  
  14. HashMap<String,String> HM_route_bus_collection_a = new HashMap<String, String>();
  15.  
  16. List<String> routeNo_set = new ArrayList<String>();
  17. routeNo_set.add("first");
  18. routeNo_set.add("second");
  19. routeNo_set.add("third");
  20.  
  21. List<String> address_set = new ArrayList<String>();
  22. address_set.add("A");
  23. address_set.add("B");
  24. address_set.add("C");
  25.  
  26. List<String> busType_set = new ArrayList<String>();
  27. busType_set.add("1");
  28. busType_set.add("2");
  29. busType_set.add("3");
  30.  
  31. for(int i = 0;i<routeNo_set.size();i++ ) {
  32.  
  33. HM_route_bus_collection_a.put("route_no", routeNo_set.get(i));
  34. HM_route_bus_collection_a.put("address", address_set.get(i));
  35. HM_route_bus_collection_a.put("bus_type", busType_set.get(i));
  36.  
  37. AL_route_bus_collection_a.add(HM_route_bus_collection_a);
  38.  
  39. HM_route_bus_collection_a = new HashMap<String, String>();
  40. }
  41. for (HashMap<String, String> hashMap : AL_route_bus_collection_a) {
  42. System.out.println(hashMap.keySet());
  43. for (String key : hashMap.keySet()) {
  44. System.out.println(hashMap.get(key));
  45. }
  46. }
  47. }
  48. }
Success #stdin #stdout 0.1s 320512KB
stdin
Standard input is empty
stdout
[address, bus_type, route_no]
A
1
first
[address, bus_type, route_no]
B
2
second
[address, bus_type, route_no]
C
3
third