JAVA泛型<T>的使用,<? extends E>和<? super E>的含义 您所在的位置:网站首页 !e和e! JAVA泛型<T>的使用,<? extends E>和<? super E>的含义

JAVA泛型<T>的使用,<? extends E>和<? super E>的含义

#JAVA泛型<T>的使用,<? extends E>和<? super E>的含义| 来源: 网络整理| 查看: 265

JAVA泛型<T>的使用

什么时候定义泛型类? 当类中要操作的引用数据类型不确定的时候,定义泛型来完成扩展。

class Demo { public void show(T t) { System.out.println("show:"+t); } public void print(Q q) { System.out.println("print:"+q); } public static void method(W t) { System.out.println("method:"+t); } }

定义在接口上的泛型

interface Inter { void show(T t); } class InterImpl implements Inter { public void show(T t) { System.out.println("show :"+t); } } class GenericDemo5 { public static void main(String[] args) { InterImpl i = new InterImpl(); i.show(4); } }


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

      专题文章
        CopyRight 2018-2019 实验室设备网 版权所有