Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. for(HashMap<String, Integer> aString : value){
  2. System.out.println("key : " + key + " value : " + aString);
  3.  
  4. }
  5.  
  6. key : My Name value : {SKI=7, COR=13, IN=30}
  7.  
  8. ArrayList<Integer> array = new ArrayList<Integer>();
  9. JSONArray json = new JSONArray(aString);
  10. for (int i =0; i< json.length(); i++) {
  11. array.add(json.getInt(i));
  12. }
  13.  
  14. Map mp;
  15. .....
  16. Iterator it = mp.entrySet().iterator();
  17. while (it.hasNext()) {
  18. Map.Entry pairs = (Map.Entry)it.next();
  19. System.out.println(pairs.getKey() + " = " + pairs.getValue());
  20. String key = pairs.getKey();
  21. String value = pairs.getValue();
  22. //Do something with the key/value pair
  23. }
  24.  
  25. ArrayList < String > ski = new ArrayList < String > ();
  26. ArrayList < String > cor = new ArrayList < String > ();
  27. ArrayList < String > in = new ArrayList < String > ();
  28.  
  29. for (HashMap < String, Integer > aString: value) {
  30. System.out.println("key : " + key + " value : " + aString);
  31. aString.replace("{", "");
  32. aString.replace("}", "");
  33. String[] items = aString.split(", ");
  34. for (String str: items) {
  35. if (str.contains("SKI")) {
  36. String skiPart = str.split("=");
  37. if (skiPart.length == 2) ski.add(skiPart[1]);
  38. }
  39. elseif(str.contains("COR")) {
  40. String corPart = str.split("=");
  41. if (corPart.length == 2) cor.add(corPart[1]);
  42. }
  43. elseif(str.contains("IN")) {
  44. String inPart = str.split("=");
  45. if (inPart.length == 2) in.add(inPart[1]);
  46. }
  47. }
  48.  
  49. }
  50.  
  51. ArrayList<HashMap<String, Object>> userNotifications = new ArrayList<HashMap<String, Object>>();
  52. int count = 0;
  53.  
  54. HashMap<String, Object> notificationItem = new HashMap<String, Object>();
  55. notificationItem.put("key1", "value1");
  56. notificationItem.put("key2", "value2");
  57. userNotifications.add(count, notificationItem);
  58. count++;
  59.  
  60. ArrayList<HashMap<String, Object>> resultGetLast5PushNotificationsByUser = new ArrayList<HashMap<String, Object>>();
  61.  
  62. resultGetLast5PushNotificationsByUser = methodThatReturnsAnArrayList();
  63. HashMap<String, Object> item1= resultGetLast5PushNotificationsByUser.get(0);
  64. String value1= item1.get("key1");
  65. String value2= item1.get("key2");
  66. HashMap<String, Object> item1= resultGetLast5PushNotificationsByUser.get(1);
  67. String value1= item1.get("key1");
  68. String value2= item1.get("key2");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement