conatiner 1

PHOTO EMBED

Thu Feb 15 2024 07:04:40 GMT+0000 (Coordinated Universal Time)

Saved by @dsce

public class Container1{
	private Object obj;
	public Container1(Object obj){
		this.obj=obj;
	}
	public Object getobj(){
		return this.obj;
	}
	public void showType(){
		System.out.println("Type is "+obj.getClass().getName());
	}
	public static void main(String[] args)
	{
		Container1 c1=new Container1("deva");
		String s1=(String)c1.getobj();
		System.out.println("String is "+s1);
		c1.showType();
		
		Container1 c2=new Container1(123);
		Integer s2=(Integer)c2.getobj();
		System.out.println("Integer is "+s2);
		c2.showType();
	}
}
content_copyCOPY