Episode 58 of the Java Series:
class Flower<A, B>{ //Creating two type parameters
A objectVariableOne;
B objectVariableTwo;
//Magical Constructor Using BOTH Parameters
public Flower(A objectVariableOne, B objectVariableTwo) {
this.objectVariableOne = objectVariableOne;
this.objectVariableTwo = objectVariableTwo;
}
public void setObjectVariableOne(A objectVariableOne) {
this.objectVariableOne = objectVariableOne;
}
public void setObjectVariableTwo(B objectVariableTwo) {
this.objectVariableTwo = objectVariableTwo;
}
public A getObjectVariableOne() {
return objectVariableOne;
}
public B getObjectVariableTwo() {
return objectVariableTwo;
}
}
public class Main {
public static void main(String[] args) {
Flower<String, Integer> flower1 = new Flower<String, Integer>("Kody is cool", 45);
System.out.println(flower1.objectVariableOne);
System.out.println(flower1.objectVariableTwo);
flower1.setObjectVariableOne("Wowww");
flower1.setObjectVariableTwo(324324124);
System.out.println(flower1.objectVariableOne);
System.out.println(flower1.objectVariableTwo);
}
}