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.


