Thursday, January 22, 2009

Stuff Java Should Nick from Python: List Literals

In Python, I can create a little list really easily:

my_list = ["one", "two", "three"]

In Java, doing something simple like this is a right pain:

List myList = new ArrayList();
myList.append("one");
myList.append("two");
myList.append("three");

This is really annoying when you want to do something quick and dirty with a list.

2 comments:

jonathanj said...

That is pretty annoying.
I was just wondering what made you say that now? Haven't you been doing Java for, like, 8 years or something? And, probably, Python for a few years?

Chris said...

Yes. I have considered it a bit annoying for a while but have only just decided to "blog" about it.