I\'ve seen a question similar to this multiple times here, but there is one big difference.
In the other questions, the return type is to be determined by the parameter.
If you are really only returning a boolean
or a float
, then the best you can do is Object
.
If you are returning variable objects, you have to choose a return type with the least common superclass. Primitives don't have a superclass, but they will be boxed into Object representations (like Boolean
and Float
) which have a common superclass of Object
.