I am quite new to Java and read about the generic inputs and classes. I was wondering if we can have a function for example named as getNewWeights(genericInput)
where the genericInput
can be different class types but they have similar functions, as follows:
public static Double getNewWeight(Class<T> genericInput) {
double weight = 0.0;
//logic
weight = genericInput.getCalcuatedWeight(INPUTS);
//logic
return weight
}
while genericInputs of any type has same getCalcuatedWeight
function.
for example: if genericInput
class type is Car or Train both of these classes have a public function as getCalcuatedWeight
that returns a double value.
No comments:
Post a Comment