Lenguaje de Programacion II (Silverio Del Orbe Abad)
Heriberto perdomo
Matricula 100459918
ASIGNACION UNIDAD 3
Unidad 3 -4 JP Oracle Academic
Generic
Exception
asertion
public class Cell<T1, T2> {
private T1 t1Value;
private T2 t2Value;
public void setValue(T1 t1, T2 t2) {
this.t1Value = t1;
this.t2Value = t2;
}
public T1 getT1Value() {
return t1Value;
}
public T2 getT2Value() {
return t2Value;
}
@Override
public String toString() {
return "Cell{" +
"t1Value=" + t1Value +
", t2Value=" + t2Value +
'}';
}
}
Clase final de CellDriver:
public class CellDriver {
public static void main(String[] args) {
Cell<Integer, String> mixCell = new Cell<>();
Cell<Integer, Integer> integerCell = new Cell<>();
[Link](1, "4");
[Link](45, 60);
int mcType1 = mixCell.getT1Value();
String mcType2 = mixCell.getT2Value();
int icType1 = integerCell.getT1Value();
int icType2 = integerCell.getT2Value();
[Link](mixCell);
[Link](integerCell);
[Link]("The numerical value is: " + mcType1 + ". The text value is: " + mcType2);
[Link]("The first numerical value is: " + icType1 + " and the second is: " + icType2);
} // end main
} // end class CellDriver