conatiner 2
Thu Feb 15 2024 07:06:23 GMT+0000 (Coordinated Universal Time)
Saved by
@dsce
public class Container2<T>{
private T obj;
public Container2(T obj){
this.obj=obj;
}
public T getobj(){
return this.obj;
}
public void showtype(){
System.out.println("type is "+obj.getClass().getName());
}
public static void main(String[] args)
{
Container2<String> c1=new Container2<String>("deva");
String s1=c1.getobj();
System.out.println("String is "+s1);
c1.showtype();
Container2<Integer> c2=new Container2<Integer>(123);
Integer s2=c2.getobj();
System.out.println("Integer is "+s2);
c2.showtype();
}
}
content_copyCOPY
Comments