| [ Web Proxy ] |
| Viewing: https://raw.githubusercontent.com/bcsangeetha/Java-Programs/master/generics/GenericClass.java | [Back] [Original] |
package generics;
public class GenericClass {
private T t;
public void add(T t) {
this.t=t;
}
public T get() {
return t;
}
public static void main(String[] args) {
GenericClass iObj=new GenericClass();
GenericClass sObj=new GenericClass();
iObj.add(10);
sObj.add(" Hello ");
System.out.println("Integer value: "+iObj.get());
System.out.println("String value: "+sObj.get());
}
}
| Web Proxy Viewer | New URL | Original Page |