class node<t> {
t data;
node<t> next;
node(t x){
this.data = x;
}
}
class zoo<t>{
node<t> head;
void add(t x){
node<t> temp = new node<t>(x);
if(head == null){
head = temp;
}
else{
temp.next = head;
head = temp;
}
}
void print(){
node<t> temp = head;
while(temp != null){
System.out.println(temp.data);
temp = temp.next;
}
}
}
class mywork{
public static void main(String args[]){
zoo<String> z1 = new zoo<String>();
z1.add("hellow");
z1.add("my love");
z1.add("jiojo");
z1.print();
zoo<Integer> z2 = new zoo<Integer>();
z2.add(89);
z2.add(23);
z2.add(67);
z2.add(90);
z2.print();
}
}
Comments
Post a Comment