I came across: import static java.lang.Float.*;
, note the static
(actually it was import static java.lang.Math.*
but that aside). I had never seen that before and thought it was very usefull, Float.valueOf("1.234f");
becomes valueOf("1.234f")
.
But when i added import static java.lang.Integer.*;
also, i got an error message: "reference to valueOf is ambiguous"
because both these classes have that (static) method.
Is there is no way around that? I can use this only a limited of times before its ambiguous somewhere?
On a sidenote:
Has this situation the same background as why we can only extend
one class, because if we could extend
two classes, for all the static fields etc, the naming could cause the same problems?