Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extend generic List

Tags:

java

list

I am a C# programmer and have agreed to help a fried doing Java homework.

In one example I want to create a class that extends a generic List. In C# this looks like

public class MyListClass : List<MyCustomType>

I have tried

public class MyListClass extends List<MyCustomType>

and get the error "no interface expected here". Well, I am not trying to use an interface... Any hints?

like image 923
Peter Avatar asked May 14 '26 22:05

Peter


1 Answers

java.util.List is a interface. You need to implement it not extend it.

public class MyListClass implements List<MyCustomType>{
}
like image 152
Subhrajyoti Majumder Avatar answered May 17 '26 10:05

Subhrajyoti Majumder



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!