Java noob: generics over objects only?

后端 未结 4 465
情深已故
情深已故 2020-11-29 12:24

I\'m new to Java. While coding a Map<>, I found out that declaring Map is a syntax error while Map is OK

4条回答
  •  不知归路
    2020-11-29 13:15

    Is it only possible in Java to instantiate generics over object types, as opposed to primitives?

    correct.

    If so, is there a noticeable performance penalty for boxing/unboxing of primitives?

    yes, there is.

    See here for a detailed description: http://java.sun.com/j2se/1.5.0/docs/guide/language/autoboxing.html

提交回复
热议问题