Abc<int> //ошибка
ps And yet, how to call them in Russian? Generic (s)?
This is a limitation of Java.
The fact is that for type erasure, the type parameter is replaced with Object
when compiled. But int
not an Object
, so this is not allowed.
You can, however, bypass the ban by using Abc<Integer>
.
With regard to the Russian-language name, the word “generics” was used in the previous question. It does not sound very much, yes.
In Russian, the established “generic” colloquially or, more formally, the “generic type”. The reason indicated above: erasing types.
You can use the third-party GNU Trove library to use collections of primitive types.
Source: https://ru.stackoverflow.com/questions/265034/
All Articles