在Java中,当类型后跟尖括号(如List< Foo>)时,这意味着什么? [英] In Java, what does it mean when a type is followed by angle brackets (as in List<Foo>)?
本文介绍了在Java中,当类型后跟尖括号(如List< Foo>)时,这意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有时在另一个对象类型声明旁看到<>内的类型对象。
例如:
NavigableMap< Double,Integer> colorMap = new TreeMap< Double,Integer>()
或
private final CopyOnWriteArrayList< EventListener> ListenerRecords =
CopyOnWriteArrayList< EventListener>();
您能否给我一个简单的解释?
java.sun.com/developer/technicalArticles/J2SE/generics/rel =nofollow noreferrer> http://java.sun.com/developer/technicalArticles/J2SE/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?
解决方案
They're known as generics in java, and templates in C++.
http://java.sun.com/developer/technicalArticles/J2SE/generics/
这篇关于在Java中,当类型后跟尖括号(如List< Foo>)时,这意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文