package test;

public class GenericTest {

public class Room<T> {
private T t;
public void add(T t){
this.t=t;
}
public T get(){
return t;
}
}

public static void main(String[] args) {
GenericTest g=new GenericTest();
Room<Integer> i=g.new Room<Integer>();
i.add(100);
System.out.println(i.get());

Room<String> s=g.new Room<String>();
s.add("s300");
System.out.println(s.get());
}
}

Generic type test java的更多相关文章

  1. java generic type

    java generic type: 类型安全.类型参数化.不需要强制转换

  2. 解决springmvc报No converter found for return value of type: class java.util.ArrayList问题

    一.背景 最近闲来无事,想自己搭建一套Spring+SpringMVC+Mybatis+Mysql的环境(搭建步骤会在以后博客中给出),结果运行程序时,适用@ResponseBody注解进行返回Lis ...

  3. java.sql.SQLException: Invalid parameter object type. Expected 'java.util.Map' but found 'java.lang.String 转载

    java.sql.SQLException: Invalid parameter object type. Expected 'java.util.Map' but found 'java.lang. ...

  4. org.hibernate.MappingException: Could not determine type for: java.util.List, at table: user, for...

    异常详情: Caused by: org.hibernate.MappingException: Could not determine type for: java.util.List, at ta ...

  5. Cannot convert 0 of type class java.lang.Integer to class java.lang.Boolean

    org.apache.catalina.core.ApplicationDispatcher invoke SEVERE: Servlet.service() for servlet jsp thre ...

  6. 解决java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.ArrayList这个问题

    今天使用SSM框架,用@ResponseBody注解,出现了这个问题 java.lang.IllegalArgumentException: No converter found for return ...

  7. 解决No converter found for return value of type: class java.util.ArrayList

    十一月 02, 2018 7:37:44 下午 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() f ...

  8. Idea中:No converter found for return value of type: class java.util.ArrayList:Json格式转换问题

    1.在搞SSM框架的时候,前端发送请求后,显示如下错误. @ResponseBody注解进行返回List<对象>的json数据时出现 nested exception is java.la ...

  9. 解决java.lang.IllegalArgumentException: No converter found for return value of type: class java.util.ArrayList的问题

    一.背景 最近闲来无事,想自己搭建一套Spring+SpringMVC+Mybatis+Mysql的环境(搭建步骤会在以后博客中给出),结果运行程序时,适用@ResponseBody注解进行返回Lis ...

随机推荐

  1. nyist oj 138 找球号(二)(hash 表+位运算)

    找球号(二) 时间限制:1000 ms  |  内存限制:65535 KB 难度:5 描写叙述 在某一国度里流行着一种游戏.游戏规则为:现有一堆球中.每一个球上都有一个整数编号i(0<=i< ...

  2. MFC补码原码反码转换工具

    /*_TCHAR str[100] = { 0 }; wsprintf(str, _T("%d"),num);*/ ; CString str; m_edit1.GetWindow ...

  3. web语义化理解

    含义: Web语义化是指使用语义恰当的标签,使页面有良好的结构,页面元素有含义,能够让人和搜索引擎都容易理解. 为什么要web语义化?如今互联网都到了web2.0的时代了,HTML语言在不断的进化并发 ...

  4. Android setImageResource与setImageBitmap的区别

    同样的布局文件,小分辨率手机: 1.使用setImageBitmap设置时,出现如下现象: 2.使用setImageResource时,图片显示正常 原因:setImageResource(id)会根 ...

  5. 【摘录】JDBC Master Slave(JDBC方式的JMS集群)

    JDBC Master Slave First supported in ActiveMQ version 4.1 If you are using pure JDBC and not using t ...

  6. SpringCloud学习笔记(10)----Spring Cloud Netflix之声明式 REST客户端 -Feign的高级特性

    1. Feign的默认配置 Feign 的默认配置 Spring Cloud Netflix 提供的默认实现类:FeignClientsConfiguration 解码器:Decoder feignD ...

  7. 数字游戏(string的sort的应用)

    题目描述 牛牛举办了一场数字游戏,有n个玩家参加这个游戏,游戏开始每个玩家选定一个数,然后将这个数写在纸上(十进制数,无前缀零),然后接下来对于每一个数字将其数位按照非递减顺序排列,得到新的数,新数的 ...

  8. mysql 将时间转换成时间戳

    select UNIX_TIMESTAMP(addtime/*date_column*/) from tablename 输出:1548658912 数据库原格式:2019-01-28 15:01:2 ...

  9. Vue异步组件Demo

    Vue异步组件Demo 在大型应用中,我们可能需要将应用拆分为多个小模块,按需从服务器下载.为了进一步简化,Vue.js 允许将组件定义为一个工厂函数,异步地解析组件的定义.Vue.js 只在组件需要 ...

  10. Docker安装MySQL忽略大小写问题的问题

    原文:Docker安装MySQL忽略大小写问题的问题 连接MySQL: 查看当前mysql的大小写敏感配置show global variables like '%lower_case%';+---- ...