Java – common types and performance

I wonder if the use of generic types in an application will have any (significant) degraded performance impact on the application I use a lot of collection objects (list, collection, mapping) and provide better flexibility for the application (this application must be integrated into other applications). I only use generic types instead of parameterizing them Is this a common practice, or does someone have suggestions / suggestions? Will there be any significant performance degradation?

Thank you in advance,

Solution

There is no performance degradation at all, because generics are actually a "compile time skill"

The compiler uses this information to reject certain types of unsafe practices that would otherwise occur at runtime if generics were not used During runtime, only the original class (i.e. the upper limit of common parameters) is used, so the performance will be the same as not using generics, and only compiling the class yourself

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>