Preview:
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();
	}
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter