0

Sorry if this is a duplicate question, however, I was not able to find the answer after searching for a while.

So after all this time Java has had generics be a run time resolution scope instead of a compile time scope like C#/.NET. I am trying to figure out the reason why the Java community has never updated to switch generics to a compile time resolution. The performance benefits would be particularly large, especially in embedded devices and Android. Thanks for any insights!

Thanks for the comments. I think I am phrasing my question poorly then. I guess what I mean is why are my generics constantly casting at runtime instead of just replacing the proper type in place at runtime. So maybe why is type erasure necessary? Would be a better question.

Matthew Fontana
  • 3,343
  • 2
  • 26
  • 48
  • Performance benefits? Generics are erased at runtime. It's at compile-time that they're any use. – Kayaman Jun 07 '16 at 11:07
  • 2
    What do you mean by Java generics being resolved at run time ? Java generic type checks happen at compile-time only. – Thilo Jun 07 '16 at 11:09
  • See [Java Documentation: Type erasure](https://docs.oracle.com/javase/tutorial/java/generics/erasure.html) – Modus Tollens Jun 07 '16 at 11:19
  • Ok after some more searching I eventually found a most that was spot on for answering my question. I really did ask it poorly, but for anyone trying to understand the same thing here is the link: http://stackoverflow.com/questions/31693/what-are-the-differences-between-generics-in-c-sharp-and-java-and-templates-i – Matthew Fontana Jun 08 '16 at 11:20

0 Answers0