The benefits of using Java generics are purely that your code is less cluttered with casts, you are able to state your intentions at compile-time about what your collections can contain and have these intentions checked by the compiler.
Java generics have nothing whatsoever to do with performance. As James Black says, because in Java, generics are erased, there is no difference at runtime between Java code which uses parameterized types and Java code which uses raw types.
So yes, we still use them because they make our code clearer
EDIT. I seem to have been downvoted because I did not realize that you were talking about the ability in C#
to have a collection of primitives (what with them not actually being mentioned anywhere in the question): e.g.
List<int>
If I really care about performance (i.e. squeezing every last microsecond from a Java program) then I'd use an int[]
array and, yes, it's a shame that Java doesn't have primitive-collections. For most programs, I don't think that this is a real issue, however, so I'm happy to use List<Integer>
in Java for its added convenience.