How to choose between two method of the same name in Java

java, overloading

Solution

Cast the first argument to the type of the first parameter of the method you want to call, for example:

methodName((A) null, y, z);

Problem

I'm trying to access a method in a class I made, but since it is similar in name and in number of arguments my IDE says the method is ambiguous. Here's a mock-up of what the two methods look like: ``` methodName(X, Y, Z) methodName(A, Y, Z) ``` I called on the method, and passed in the value `null` for the first argument for the purpose of my test. Unfortunately I cannot rename the methods, change the order of the arguments or modify the structure of the method in any way. Is there a way I can differentiate between these two methods?

Original source

Related problems