Question: Subject: Java Problem 1: Generic Class 1. Create a generic class GenericClass with 3 formal type parameters. 2. Declare 3 instance variables one of each
Subject: Java
Problem 1: Generic Class
1.
Create a generic class GenericClass with 3 formal type parameters.
2.
Declare 3 instance variables one of each formal type
3.
Define get and set methods for each instance variable
4.
Define toString method that displays the values of the three instance variables
5.
Declare a driver class that tests the functionality of the Generic Class
Example:
public class
Pair
{
A
first;
B second;
public
Pair (
A
a, B b){
first = a;
second = b;
}
public
A
getFirst(){
return
first;
}
public
B getSecond(){
return
second;
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
