Passing Interface to constructor of class implementing the Interface

444 Views Asked by At

I have a class Twitter which implements Interface Twitter.IHttpClient. Now contructor for Twitter uses same interface as paramter.

Twitter(java.lang.String name, Twitter.IHttpClient client);

How is that possible? As interface Twitter.IHttpClient will be member of Twitter class itself and I can't create a Twitter class without it through constructor? or

I am understanding wrongly?

1

There are 1 best solutions below

0
Mena On

Twitter.IHttpClient is a static nested interface of the Twitter class.

As such, it is scoped statically and won't require an instance of Twitter.