首页 > 编程语言 > 详细

Java generics

时间:2016-02-19 06:52:01      阅读:244      评论:0      收藏:0      [点我收藏+]

Provides compile-time type safety for collections and eliminates the pain of casting. Generics creates strongly typed classes to do generic operation.

1 Vector v = new Vector();
2 v.add("hello");
3 v.add(new Integer(1));
4 v.add(new HashTable());
5 
6 String s = (String)v.get(0);
  • Performs strongly type check in compile time
  • Eliminates casting
  • Enable programmers to implement generic algorithms, which can be used on different types.

Java generics

原文:http://www.cnblogs.com/touchdown/p/5199685.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!