welcome to my blargh

now with 88.333% more desu. repeating of course.

« Back to blog

Lists in C# versus Java

Here's how you create and iterate over a list in C#:

Now, here's that same code in Java:

As you can see, the Java code is a bit more verbose. While C# defines its List class as a strongly typed class, Java treats its own as a very generic collection that requires you to cast elements as you access them. Also, C# does some synaptic sugar with its "foreach" statement that automatically accesses the iterator and loops through the collection.

Loading mentions Retweet

 
To leave a comment on this posterous, please login by clicking one of the following.
Posterous-login     Connect     twitter