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

后端 未结 7 811
闹比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:08

    These are called Generics in Java. They give you a way to tell the compiler what type the collection is going to hold.

    http://java.sun.com/j2se/1.5.0/docs/guide/language/generics.html

提交回复
热议问题