jhyot
jhyot

Reputation: 3955

Overriding method only calls parent method - useful?

I was looking through an old codebase and I found a method that only calls its parent:

@Override
public void select(Object item) {
  super.select(item);
}

Would there be any use case for such a method? For me it looks like I could just remove it.

Upvotes: 6

Views: 78

Answers (2)

Eran
Eran

Reputation: 393771

Yes, this method can be removed without changing the logic of your code.

Perhaps it used to have a different implementation which was removed, or was supposed to have a different implementation which was never written.

Upvotes: 5

zmbq
zmbq

Reputation: 39013

Removing it would make almost no difference. You will see a difference when using reflection and looking for the select method on the object. If you ask tell reflection not to look in the object's base class, it's not going to find the method after you delete it.

Upvotes: 7

Related Questions