I wanted to check, if my Generics are of the type Integer. If they are, they should get converted to double and afterwards should be added together. I get the error "The operator * is undefined for the argument type(s) E, double". There is also the same problem afterwards with adding the two casted values together.
How can I fix this?
Thanks in advance :)
public void add(E value1, E value2) {
if(value1 instanceof Integer && value2 instanceof Integer) {
double valueCast1 = value1 * 1.0;
double valueCast2 = value2 * 1.0;
System.out.println(value1 + value2);
}
}