20 lines
412 B
Java
20 lines
412 B
Java
public class GenericClass9B<T> {
|
|
private T t;
|
|
|
|
public void add(T t){
|
|
this.t = t;
|
|
}
|
|
|
|
public T get(){
|
|
return t;
|
|
}
|
|
|
|
public static void main(String[] args){
|
|
GenericClass9B<Integer> rhombus = new GenericClass9B<Integer>();
|
|
GenericClass9B<Double> circle = new GenericClass9B<Double>();
|
|
rhombus.add(33);
|
|
circle.add(16.9);
|
|
System.out.println(rhombus.get());
|
|
System.out.println(circle.get());
|
|
}
|
|
} |