码迷,mamicode.com
首页 > 编程语言 > 详细

Java generics

时间:2016-02-19 06:53:59      阅读:206      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!