package com.china.hc;
public class GenericMethodTest04<T extends Number> { // 泛型的上限(只能接受Number类型及Number的子类)
private T t;
public T getT() {
return t;
}
public void setT(T t) {
this.t = t;
}
public String printString() {
return this.t.toString();
}
public static void main(String[] args) {
GenericMethodTest04<Integer> info = new GenericMethodTest04<Integer>();
info.setT(123);
System.out.println("泛型上限的使用:" + info.printString());
}
}