Category Archives: Android

Creating and intitializing ArrayList in one line

There are multiple ways of creating a ArrayList and adding a couple of items to it.  The usual way to do it: List<String> normal = new ArrayList<String>(); normal.add("one"); normal.add("two"); normal.add("three"); Or you could use the double braces. The inner pair of braces creates a anonymous innner class List<String> doubleBraces = new ArrayList<String>() {{ add("one"); add("two"); […]