指定多个泛型类型
来源:互联网 发布:淘宝天天特价规则 编辑:程序博客网 时间:2024/06/06 01:40
class Notepad<K,V>{
private K key;
private V value;
public K getKey() {
return key;
}
public void setKey(K key) {
this.key = key;
}
public V getValue() {
return value;
}
public void setValue(V value) {
this.value = value;
}
}
public class Test {
public static void main(String[] args) {
Notepad<String,Integer> t = null;
t = new Notepad<String,Integer>();
t.setKey("张三");
t.setValue(30);
System.out.println(t.getKey()+"---"+t.getValue());
}
private K key;
private V value;
public K getKey() {
return key;
}
public void setKey(K key) {
this.key = key;
}
public V getValue() {
return value;
}
public void setValue(V value) {
this.value = value;
}
}
public class Test {
public static void main(String[] args) {
Notepad<String,Integer> t = null;
t = new Notepad<String,Integer>();
t.setKey("张三");
t.setValue(30);
System.out.println(t.getKey()+"---"+t.getValue());
}
}
运行结果:
张三---30
0 0
- 指定多个泛型类型
- 指定多个泛型类型
- 数组类型指定为指定数组类型
- traceroute 指定发包类型
- 复制指定类型文件
- android指定输入法类型
- 指定EditText输入类型
- 图片上传指定类型
- 指定lambda返回类型
- java获取指定目录指定类型文件
- linux 删除指定文件夹指定大小指定类型的文件
- 查找指定类型的驱动器
- 查找指定类型的驱动器
- 设置文件属性,指定其类型
- 压缩指定类型的文件
- 字符串转换成指定类型
- 指定集合元素的类型
- 创建表并指定类型
- ATOM基础教程一ATOM代码片段snippets(7)
- yii 框架用swiftmailer 发送邮件
- 约瑟夫环问题
- ccnuacm
- 在linux编程中,以下哪个TCP的套接字选项与nagle算法的开启和关闭有关?----腾讯2016研发工程师在线模拟笔试题
- 指定多个泛型类型
- 引入sys/timeb.h后,timeb can not be resolved
- C++多态实现机制剖析
- SpringMVC中使用Interceptor拦截器
- ArrayList与HashSet的比较,以及HashCode分析, 内存泄露
- 集训开始
- Codeforces Round #315 (Div. 2)-B. Inventory
- PAT乙级练习题B1039. 到底买不买
- 编辑器 NicEdit 富文本web编辑器