This commit is contained in:
Aditya Tiwari
2026-02-05 14:06:41 +05:30
parent 1d7f4992d3
commit 2db1ec2c4d
4 changed files with 21 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
// write a program for Generic class
// write a program for Generic class 9A
public class GenericClass9A <T1, T2> {
public void display (T1 var1, T2 var2){
System.out.println("Name: "+var1 + " ID: " + var2);

BIN
GenericClass9B.class Normal file

Binary file not shown.

20
GenericClass9B.java Normal file
View File

@@ -0,0 +1,20 @@
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());
}
}

BIN
src/9B.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB