import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
public class NumberTest {
public static void main(String[] args) {
Map<String, ArrayList<Number>> map = new LinkedHashMap<String, ArrayList<Number>>();
String firstKey = "FirstItem";
ArrayList<Number> firstValue = new ArrayList<Number>();
firstValue.add(100);
firstValue.add(200);
firstValue.add(300);
map.put(firstKey, firstValue);
String secondKey = "SecondItem";
ArrayList<Number> secondValue = new ArrayList<Number>();
secondValue.add(100.11);
secondValue.add(200.22);
secondValue.add(300.33);
map.put(secondKey, secondValue);
System.out.println(map);
show(map);
}
static void show(Map<String, ArrayList<Number>> map) {
for (Map.Entry<String, ArrayList<Number>> entry : map.entrySet()) {
if (entry.getValue().get(0) instanceof Integer) {
System.out.println("Key = '" + entry.getKey() + "', value is Integer.");
for (Number m : entry.getValue()) {
System.out.println("Key = '" + entry.getKey() + "', value = '" + m + "'.");
}
}
if (entry.getValue().get(0) instanceof Double) {
System.out.println("Key = '" + entry.getKey() + "', value is Double.");
for (Number n : entry.getValue()) {
System.out.println("Key = '" + entry.getKey() + "', value = '" + n + "'.");
}
}
}
}
}
{FirstItem=[100, 200, 300], SecondItem=[100.11, 200.22, 300.33]}
Key = 'FirstItem', value is Integer.
Key = 'FirstItem', value = '100'.
Key = 'FirstItem', value = '200'.
Key = 'FirstItem', value = '300'.
Key = 'SecondItem', value is Double.
Key = 'SecondItem', value = '100.11'.
Key = 'SecondItem', value = '200.22'.
Key = 'SecondItem', value = '300.33'.