Create type specific collections
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
Map<Integer, String> grades = new HashMap<Integer, String>();
grades.put(1, "A");
grades.put(2, "B");
grades.put(3, "C");
grades.put(4, "D");
grades.put(5, "E");
String value = grades.get(1);
List<String> dayNames = new ArrayList<String>();
dayNames.add("Sunday");
dayNames.add("Monday");
dayNames.add("Tuesday");
dayNames.add("Wednesday");
String firstDay = dayNames.get(0);
}
}
Related examples in the same category