java - Compact syntax for instantiating an initializing collection -


i'm looking compact syntax instantiating collection , adding few items it. use syntax:

collection<string> collection =      new arraylist<string>(arrays.aslist(new string[] { "1", "2", "3" })); 

i seem recall there's more compact way of doing uses anonymous subclass of arraylist, adds items in subclass' constructor. however, can't seem remember exact syntax.

http://blog.firdau.si/2010/07/01/java-tips-initializing-collection/

list<string> s = arrays.aslist("1", "2"); 

Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -