I've the following code in Java:
void foo(int a) { ... }
void bar() {
Long x = 42;
foo(x); // Compile error: "Method foo(int)
// is not applicable for the argument (long)"
foo((long) x); // Same as before
foo((int) x); // Compile error: "Cannot cast Long to int"
foo((int) (long) x); // OK, but strange and confusing
}
Is there a better way?