Reputation: 176
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.
Upvotes: 0
Views: 514
Reputation: 48258
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 ....
Upvotes: 5