0

I created an interface:

public interface Random<E>{
    // methods signatures
}

I know it is unusual to do so but I need to make a class extending the ArrayList class and implements this interface, so I write some code likes this:

public class RandomTest<E> implements Random<E> extends ArrayList<E>{
   // a lot of code
   // overriding methods

    public static void main(String[] args){
    RandomTest<Integer> list = new RandomTest<Integer>();
}

But it can't compile. Just keep showing -

"Syntax error on token "extends", , expected."

I am confused.

1 Answer 1

5

You are coding in java, the syntax is

Class A extends B implements C,D,E.....

you have changed the orders of extends implements....

replace

public class RandomTest<E> implements Random<E> extends ArrayList<E>{

for

class RandomTest<E> extends ArrayList<E> implements ....
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.