Create a List of primitive int?

In Java the type of any variable is either a primitive type or a reference type. Generic type arguments must be reference types. Since primitives do not extend Object they cannot be used as generic type arguments for a parametrized type. Instead use the Integer class which is a wrapper for int: If your using Java 7 you can simplify … Read more

foreach vs someList.ForEach(){}

There are apparently many ways to iterate over a collection. Curious if there are any differences, or why you’d use one way over the other. First type: Other Way: I suppose off the top of my head, that instead of the anonymous delegate I use above, you’d have a reusable delegate you could specify…

and in Java – why it works this way?

The way I look at it is this – the placeholder T stands in for a definite type and in places where we need to know the actual type we need to be able to work it out. In contrast the wildcard ? means any type and I will never need to know what that type is. You can … Read more