Link Details

Link 61307 thumbnail
User 111696 avatar

By bloid
via gleichmann.wordpress.com
Published: Jan 13 2008 / 16:43

The rise of some ‘new’ languages like Ruby, Groovy and Scala is (among other things) accompanied with discussions about the verbosity of some established languages, especially Java. For example there are not few voices, complaining about the boilerplate code that you have to write (and read) when it comes to the declaration and instantiation of collection types in Java.
  • 8
  • 1
  • 1753
  • 502

Comments

Add your comment
User 236137 avatar

dzonelurker replied ago:

0 votes Vote down Vote up Reply

How about Arrays.asList()

User 170724 avatar

magle replied ago:

0 votes Vote down Vote up Reply

You're absolutely right - but i'm afraid that there would still be complaints that this isn't concise enough, i.e. when declaring a kind of matrix using Lists:

Array.asList( Array.asList( 1, 2, 3 ), Array.asList( 4, 5, 6 ), Array.asList( 7, 8, 9 ), ... )
vs.
List( List( 1,2,3 ), List( 4,5,6 ), List( 7,8,9 ), ... )

Regards

Mario

User 183924 avatar

afsina replied ago:

0 votes Vote down Vote up Reply

static imports.
asList( asList( 1, 2, 3 ), asList( 4, 5, 6 ),asList( 7, 8, 9 ), ... )

but still a new syntax would not hurt.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Voters For This Link (8)



Voters Against This Link (1)