How do I return a custom object which uses generic as an empty list?
I have extended the List interface and created my own custom type
public interface MyCustomList<T>
extends List<T>
{
In a class, I have a method which returns a custom list but I always end up with a compiler error. Basically the default implementation of this method should return an empty list but I cant get it to work since I am encountering below error.
‘incompatible types’
public MyCustomList<MyCustomBean> getCodes(String code)
{
return Collections.<MyCustomList<MyCustomBean>>emptyList();
}
Whats the proper way of sending back a ‘generified’ empty list implementation?
Anything wrong with a perfunctory impl?