Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java "implement interface"?

I know "implement interface" means: A class implement a interface. Now I met a puzzle in Android Studio (In IntelliJ IDEA, there has a similar doubts.): Note the following picture: When Child implement the Interface, and override the method fun2, there will be a specific icon on the left.But the Parent don't implement the Interface, why an same icon appear?

Bigger picture here

like image 866
kangjianwei Avatar asked Oct 30 '22 07:10

kangjianwei


1 Answers

In the full version of IntelliJ with the 3 example classes you posted above, the icon you refer to has hover text:

Implements method in Interface via sub-class Child

In other words IntelliJ is smart enough to see the association between the interface and the inheritance structure.

Why does it do this? Well if you remove the definition of fun1 from Child class, then fun1 is of course visible in Child class via inheritance from Parent, thereby fulfilling the requirement to implement Interface.

like image 126
vikingsteve Avatar answered Nov 15 '22 06:11

vikingsteve