Does Generics in Java give any performans advantage over collections.
For example in C# there is a performance advantage as it helps to avoid boxing/unboxing, but as I understand in Java there is no "idea" of generics at byte code level, so after compilation it has the same byte code as for collections.
So is it right to say that there is no performance advantage?
I think this link can be very helpful .
Comparing Java and C# Generics
As you have said in C# performance will benefit as Generics helps you to avoid boxing/unboxing. In depth the reason is that .NET generics support value types but Java generics don't work with the primitive types and that is why it can't remove the overhead of boxing/unboxing.
But still you have compile time type checking and no need of explicit casts in your code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With