- //新曙光培训@西安
- //www.xinshuguang.org
- class VerySimpleFanXing<T>{
- public T HaiNaBaiChuan;
- //海纳百川
- }
- public class VSFXtest{
- public static void main(String[] args){
- VerySimpleFanXing<String> one=new VerySimpleFanXing<String>();
- VerySimpleFanXing<Integer> two=new VerySimpleFanXing<Integer>();
- one.HaiNaBaiChuan="新曙光";
- two.HaiNaBaiChuan=8;
- //String 和Integer是不同类型的数据
- //但是都放到变量HaiNaBaiChuan
- //中了
- System.out.println(one.HaiNaBaiChuan);
- System.out.println(two.HaiNaBaiChuan);
- }
- }
一个最简单的泛型例子
最新推荐文章于 2023-03-26 19:39:12 发布