泛型高级通配符
来源:互联网 发布:tower mac 编辑:程序博客网 时间:2024/05/17 23:30
package niu.cheng5;
import java.util.ArrayList;
import java.util.Collection;
/*
* 泛型高级通配符
* ?:
* ?extends E:
* ?super E:
*/
public class FanGao {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
/*
//泛型明确些的时候,前后必须一致
Collection<Object> c1=new ArrayList<Object>();
Collection<Object> c2=new ArrayList<Dong>();
Collection<Object> c3=new ArrayList<Dog>();
Collection<Object> c4=new ArrayList<Cat>();
*/
/*
//? 表示任意类型都是可以的
Collection<?> c1=new ArrayList<Object>();
Collection<?> c2=new ArrayList<Dong>();
Collection<?> c3=new ArrayList<Dog>();
Collection<?> c4=new ArrayList<Cat>();
*/
/*
// ?extends E:向下限定,限定E及其子类
Collection<? extends Dong > c1=new ArrayList<Object>();
Collection<? extends Dong> c2=new ArrayList<Dong>();
Collection<? extends Dong> c3=new ArrayList<Dog>();
Collection<? extends Dong> c4=new ArrayList<Cat>();
*/
/*
//?super E: 向上限定,限定E及其父类
Collection<? super Dong > c1=new ArrayList<Object>();
Collection<? super Dong> c2=new ArrayList<Dong>();
Collection<? super Dong> c3=new ArrayList<Dog>();
Collection<? super Dong> c4=new ArrayList<Cat>();
*/
}
}
class Dong{
}
class Dog extends Dong{
}
class Cat extends Dong{
}
import java.util.ArrayList;
import java.util.Collection;
/*
* 泛型高级通配符
* ?:
* ?extends E:
* ?super E:
*/
public class FanGao {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
/*
//泛型明确些的时候,前后必须一致
Collection<Object> c1=new ArrayList<Object>();
Collection<Object> c2=new ArrayList<Dong>();
Collection<Object> c3=new ArrayList<Dog>();
Collection<Object> c4=new ArrayList<Cat>();
*/
/*
//? 表示任意类型都是可以的
Collection<?> c1=new ArrayList<Object>();
Collection<?> c2=new ArrayList<Dong>();
Collection<?> c3=new ArrayList<Dog>();
Collection<?> c4=new ArrayList<Cat>();
*/
/*
// ?extends E:向下限定,限定E及其子类
Collection<? extends Dong > c1=new ArrayList<Object>();
Collection<? extends Dong> c2=new ArrayList<Dong>();
Collection<? extends Dong> c3=new ArrayList<Dog>();
Collection<? extends Dong> c4=new ArrayList<Cat>();
*/
/*
//?super E: 向上限定,限定E及其父类
Collection<? super Dong > c1=new ArrayList<Object>();
Collection<? super Dong> c2=new ArrayList<Dong>();
Collection<? super Dong> c3=new ArrayList<Dog>();
Collection<? super Dong> c4=new ArrayList<Cat>();
*/
}
}
class Dong{
}
class Dog extends Dong{
}
class Cat extends Dong{
}
0 0
- 泛型高级通配符
- JDK高级特性--有限通配符泛型
- 泛型高级——通配符
- 集合框架-泛型高级之通配符
- java高级特性之泛型与通配符
- 集合框架_泛型高级之通配符
- Java--泛型(方法泛型,接口泛型,泛型高级之通配符)
- java语言基础(70)——集合框架(泛型高级之通配符)
- Excel高级检索--通配符
- SQL 通配符 高级教程
- 泛型中的?通配符
- 泛型通配符
- java泛型通配符
- java泛型通配符
- 泛型通配符
- 泛型通配符
- java泛型通配符
- Java泛型通配符
- 多态性之编译期多态和运行期多态(C++版)
- ArrayList三种遍历
- 增强for
- Android开发实践:Java层与Jni层的数组传递
- C++delete和delete[]的区别
- 泛型高级通配符
- 通过onActivityResult()先跳转到联系人界面,然后把传回来的手机号显示到应用的EditText上
- Computer Vision: Algorithms and Applications(学习笔记二)--geometric transformations
- 可变参数
- 编程折腾记
- 修改cmd字体为Consolas
- mysql select中子查询中使用强制索引的优化案例
- 遍历嵌套集合
- 2015 10 28  函数