程序运行时性能不会发生改变。
java源代码:
Generics are implemented by type erasure: generic type information is present only
at compile time, after which it is erased by the compiler.
翻译:泛型由类型擦除实现:泛型类型信息只在编译时出现,然后由编译器擦除。
可理解为:泛型是为了在编译时检查错误而存在的,当程序运行时,泛型会擦除,转为Object,所以程序运行性能不会发生改变。
网友评论