I have a method that does the same thing to multiple data types. Think:
How can I modify that so it will take and return int, float, or double, depending on what it's passed? There's no type mixing, if 1 value is a float they're all floats.
Been farting with Generics and Integer, Float, and Double with no joy.
My code's a bit more involved, I've been using the bit above to try and get something to compile.
Code:
float update(float value, float minimum, float maximum) {
if(value < minimum)
value = minimum;
else if(value > maximum)
value = maximum;
return value;
}
Been farting with Generics and Integer, Float, and Double with no joy.
My code's a bit more involved, I've been using the bit above to try and get something to compile.
Last edited: