Can someone please provide an example of creating a Java ArrayList and HashMap on the fly? So instead of doing an add() or put()
ArrayList
HashMap
add()
put()
A nice way of doing this is using Google Collections:
List list = ImmutableList.of("A", "B", "C"); Map map = ImmutableMap.of( 1, "A", 2, "B", 3, "C");