I am sure that this is elementary, but I'm at a standstill. The example is extremely simplified, but boils down to the following. I have some overloaded methods in a class like:
public void build(MyImplOneOfAnInterface item);
public void build(MyImplTwoOfAnInterface item);
Then I have another method that does the following:
public void buildIt(MyInterface item) {
build(item);
}
When I try to compile, I get the following error:
can't find character
This is because the JVM cannot determine the implementation of the interface at compile time, so that it knows what overloaded method to call.
How can this be solved at runtime? It seems that the JVM should be able to understand this.
PS: I do not want to define a method that takes an interface as an argument, and then executes a bunch of if / else statements using instanceof statements.