For examplehtml
List<String> temp = new ArrayList<String>(Arrays.asList("1", "12"));
https://stackoverflow.com/que...java
If you're only interested in the keys, you can iterate through the keySet() of the map:算法
Map<Object, Object> map = ...; for (Object key : map.keySet()) { // ... }
If you only need the values, use values():api
for (Object value : map.values()) { // ... }
Finally, if you want both the key and value, use entrySet():oracle
for (Map.Entry<Object, Object> entry : map.entrySet()) { Object key = entry.getKey(); Object value = entry.getValue(); // ... }
public class test { public static void main(String[] args) { int i1=0, i2=0, i3=0, i4=0, index1=0, index2=0, index3=0, index4=0; int[] num1 = new int[10]; int[] num2 = new int[10]; int[] num3 = new int[10]; int[] num4 = new int[10]; while (index1 < 5 && index2 < 5 && index3 < 5 && index4 < 5) { num1[index1++] = i1++; //01234 num2[++index2] = i2++; //001234 num3[index3++] = ++i3; //12345 num4[++index4] = ++i4; //012345 } for (int n : num1) { System.out.print(n); } System.out.println(); for (int n : num2) { System.out.print(n); } System.out.println(); for (int n : num3) { System.out.print(n); } System.out.println(); for (int n : num4) { System.out.print(n); } } } /* Output * 0123400000 * 0012340000 * 1234500000 * 0123450000 */