Look at this class
abstract class LolCat<T> {
T execute() throws Err, Arr {
T lol = doSomething();
if (lol == null)
lol = doSomething();
return lol;
}
abstract T doSomething();
abstract T doSomething() throws Err, Arr;
}
Now we have an anonymous implementation in some whatever method somewhere, of the LolCat like this
final UhmLetsSayCat cat = new ImplLolCat<UhmLetsSayCat>() {
@Override
UhmLetsSayCat doSomething() {
return null; // somehow a UhmLetsSayCat is returned for real sometimes null
}
@Override
UhmLetsSayCat doSomething() throws Err,Arr {
return null; // really it does right thing, whatever
}
}.execute();
Now my question is, how come the first call to doSomething() goes to the method that does not throw Err,Arr but the second call, if lol is null, runs the doSomething implementation which throws Err,Arr. How is this distinction made between which methods to run!?
EDIT: FALSE ALARM. OMG. I must have been blind the whole evening, doSomething is actually not the same method names, they where called querryAll and QuerryAl1, im gonna find the guy who did it and smack him.
EDIT2: Thanks everyone.
You can’t have two methods with the same signature declared in a class. The
throwsclause , annotations and return type don’t count.If this compiles, there is a bug in your compiler.