Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

generics

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

NavigableMap<Double, Integer> colorMap = new TreeMap<Double, Integer>()
or
private final CopyOnWriteArrayList<EventListener> ListenerRecords =
new CopyOnWriteArrayList<EventListener>(); 

Could you give me an easy explication?

like image 568
soneangel Avatar asked Nov 29 '22 19:11

soneangel


1 Answers

They're known as generics in java, and templates in C++.

http://java.sun.com/developer/technicalArticles/J2SE/generics/

like image 74
Bill Lynch Avatar answered Dec 16 '22 11:12

Bill Lynch