generics meaning in java code example
Example: java generics
public class Tuple <T> {
public T leftValue;
public T rightValue;
public Tuple(T leftValue, T rightValue){
this.leftValue = leftValue;
this.rightValue = rightValue;
}
public class Program{
public static void main (String args){
Tuple <int> intTuple = new Tuple <int>(5, 500)
Tuple <String> stringTuple = new Tuple <String> ("Hello", "World")
Tuple<Tuple<int>> metaIntTuple = new Tuple <Tuple <int>> (intTuple, new Tuple <int> (456, 0));
}
}