Initialization of list/map in one line
ListArrayList
places = new ArrayList(Arrays.asList("Buenos Aires", "Córdoba", "La Plata"));
ArrayList list = new ArrayList() {{
add("A");
add("B");
add("C");
}}
link
Map
Map m = new HashMap() {
{
put(".jpg", "image/jpeg");
put(".jpeg", "image/jpeg");
}
};
No comments:
Post a Comment