Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing interface with inner interface

Tags:

java

interface

I want to implement an interface which has inner interface. I have problem with overriding setter method. Here is draft of my problem:

Interfaces hierarchy:

public interface A {
    public interface B {}
    public void setBs(List<B> list);
}

Implementation:

public class AImpl implements A {
    private List<BImpl> listOfBs;
    public static class BImpl implements B {}
    @Override
    public void setBs(... list) { listOfBs = list }
}

What should be the type of setBs(... list) method's parameter? List<? extends B> doesn't override superclass's method.

like image 740
mystic123 Avatar asked Jan 19 '26 02:01

mystic123


1 Answers

As mentioned by fantarama, signature should be public void setBs(List<B> list).

If you're getting the error in your IDE or build framework, make sure your java compiler and target versions are set correctly.

like image 50
gar Avatar answered Jan 21 '26 16:01

gar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!