Abc<int> //ошибка 

ps And yet, how to call them in Russian? Generic (s)?

  • I once wrote an answer to this question on hashcode - just the creators of java were a bit lazy and did not. But no one interfered, except for laziness. Just a little advanced boxing / unboxing would appear. - KoVadim

2 answers 2

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.

  • 3
    In addition to the answer: as for their name in Russian - they have long been called generics, based on the obvious rules for the transcription of English words (the letter g in front of e, i, y is read as "j" and not "g". In rare In cases where this rule is violated (give, get, gift)). In C ++, these types are called templates, but this is somewhat different - DreamChild
  • In the book of Schildt they are called generalized types or generalizations - woland
  • one
    > In the book of Shildt, they are called generalized types or generalizations of Justice for the sake of Herbert Schildt - this is an American author. Therefore, he writes in a great and mighty English language, and all Russian-language names are the result of the work of a translator. Consequently, this is hardly inherent in Schildt’s purely book. - DreamChild
  • > In the book of Shildt, they are called generalized types or generalizations of Justice for the sake of Herbert Schildt - this is an American author. Therefore, he writes in a great and mighty English language, and all Russian-language names are the result of the work of a translator. Consequently, this is hardly inherent in Schildt’s purely book. But generally agree - "generalizations" sound quite well - DreamChild

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.