int[] arr = {1,2,3,4,5,6};
for(int i =0; i<arr.length; i++){
System.out.println("key " + arr[i]);
}
----------------
ArrayList<Integer> arr = new ArrayList<>();
arr.add(1);
arr.add(3);
arr.add(5);
arr.add(6);
for(int i =0; i<arr.size(); i++){
System.out.println("key " + arr.get(i));
}
--------------
Map<String, Integer> map = new HashMap<String, Integer>();
map.put("key", 11);
map.put("key1", 11);
map.put("key2", 11);
map.put("key3", 15);
map.put("key4", 11);
map.put("key5", 11);
map.put("key6", 11);
for(Map.Entry<String, Integer> entry : map.entrySet()){
String key = entry.getKey();
int value = entry.getValue();
System.out.println(" "+ key + " "+ value);
}
---------------------------
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter