How can type safety be guarded against implicit conversion in Java?
java
Solution
Bruno's overloading will work, but if you are looking at preventing other types of casting, you can always box the integer into its Object class:
void foo(Integer i) {
// handle data normally
}
This will prevent you from being able to send short arguments to it.
Problem
Suppose a method is as following: ``` void foo(int i) { } ``` Is there a way to make the following call illegal or generate an exception? ``` foo((short)3); ```