Python_user
Python_user

Reputation: 1574

Interface implementing another interface in android developer reference docs

May be I am missing some understanding or may be I am unable to understand some "wording" (I am fairly new to JAVA and android), but if you look at the developer reference docs for android, then one can find that an interface is "implementing" another interface. For example, among others, look at ComponentCallbacks2 & SurfaceHolder.Callback2. But, as per an SO post, an interface cannot implement another interface, it can only extend one. So, what is going on in the android reference docs? Shouldn't the keyword "extends" be used in the android reference docs, instead of "implements" when it comes to relationships between interfaces?

Also, say an interface interfaceB implements another interface interfaceA and a class, say ClassXYZ, implements interfaceB. While declaring the class in the reference docs, sometimes it is mentioned as:

public class ClassXYZ implements interfaceB 

(for example, in the declaration of Activity, it is mentioned that Activity class implements ComponentCallbacks2, but it is not mentioned that Activity implements ComponentCallbacks even if ComponentCallbacks2 "implements" ComponentCallbacks2)

and sometimes as

public class ClassXYZ implements interfaceB, interfaceA

(for example, in the declaration of AlteredCharSequence, it is mentioned that AlteredCharSequence class implements CharacterSequence, and it is mentioned that AlteredCharSequence implements GetChars even if GetChars "implements" CharSequence)

What is the difference between the two declarations? How does the class inheritance diagram look in both the cases?

Upvotes: 0

Views: 67

Answers (1)

khelwood
khelwood

Reputation: 59111

I think the android docs are simply using the wrong terminology. ComponentCallbacks2 extends ComponentCallbacks. Interfaces are not implementations. See some source.

As for the rest, if interface B extends interface A, then any implementation of B is also an implementation of A, even if the documentation fails to describe it as such. So any class that implements ComponentCallbacks2 does implement ComponentCallbacks, whether the docs mention it or not.

Upvotes: 1

Related Questions