Java泛型的使用方法是什么
本篇内容介绍了“Java泛型的使用方法是什么”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

创新互联建站专注于珠山网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供珠山营销型网站建设,珠山网站制作、珠山网页设计、珠山网站官网定制、小程序定制开发服务,打造珠山网络公司原创品牌,更为您提供珠山网站排名全网营销落地服务。
public class App {
public void print(Collection> coll){
System.out.println("I am Collection!!!");
}
public void print(ArrayList> arr){
System.out.println("I am ArrayList!!!");
}
public void print(Set> arr){
System.out.println("I am Set!!!");
}
public void print(HashSet> arr){
System.out.println("I am HashSet!!!");
}
public static void main(String[] args) {
App app = new App();
Collection coll = new ArrayList<>(Arrays.asList("1","2","3"));
app.print(coll);
Set set = new HashSet(Arrays.asList("1","2","3"));
app.print(set);
//运行结果:
//I am Collection!!!
//I am Set!!!
}
}“Java泛型的使用方法是什么”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注创新互联网站,小编将为大家输出更多高质量的实用文章!
本文标题:Java泛型的使用方法是什么
URL标题:http://www.cqwzjz.cn/article/pciggg.html


咨询
建站咨询
