In Java, what does it mean when a type is followed by angle brackets (as in List)?

后端 未结 7 816
闹比i
闹比i 2020-12-21 02:34

I saw sometimes a type object inside <> beside of another object type declaration. For instance:

NavigableMap colorMap = new Tree         


        
7条回答
  •  不知归路
    2020-12-21 03:14

    In your example TreeMap the key of the TreeMap has type Double and the value referenced by this key has the type Integer. And as already answered it's called generics. This is an extension introduced in java 1.5. This makes code more readable

提交回复
热议问题