zoukankan      html  css  js  c++  java
  • 随笔49 关于泛型

    1 class A {}
    2 class B extends A {}
    3 class C extends A {}
    4 class D extends B {}
    5 Which four statements are true ?
    1. 只看尖括号里边的!!明确点和范围两个概念
    2. 如果尖括号里的是一个类,那么尖括号里的就是一个点,比如List<A>,List<B>,List<Object>
    3. 如果尖括号里面带有问号,那么代表一个范围,<? extends A> 代表小于等于A的范围,<? super A>代表大于等于A的范围,<?>代表全部范围
    4. 尖括号里的所有点之间互相赋值都是错,除非是俩相同的点
    5. 尖括号小范围赋值给大范围,对,大范围赋值给小范围,错。如果某点包含在某个范围里,那么可以赋值,否则,不能赋值
    6. List<?>和List 是相等的,都代表最大范围
    ----------------------------------------------------------------------------------
    7.补充:List既是点也是范围,当表示范围时,表示最大范围
    1 The type List<A>is assignable to List.对
    2 The type List<B>is assignable to List<A>.错
    3 The type List<Object>is assignable to List<?>.对
    4 The type List<D>is assignable to List<?extends B>.对
    5 The type List<?extends A>is assignable to List<A>.错
    6 The type List<Object>is assignable to any List reference.错
    7 The type List<?extends B>is assignable to List<?extends A>.对
  • 相关阅读:
    Centos7 Apache 2.4.18编译安装
    Centos7 mysql-community-5.7.11编译安装
    Centos7 安装MPlayer过程详解
    Vmware虚拟机克隆的网卡问题
    虚拟机VMware新增硬盘无法识别问题
    python推导式
    Python迭代器和生成器
    Python装饰器
    Python函数初识二
    Python函数初识
  • 原文地址:https://www.cnblogs.com/lyr612556/p/7846169.html
Copyright © 2011-2022 走看看