I'm trying to implement extended collections as an interface and the method of keep sending me "Non-static method 'of(java.util.Collection<ELEMENT_TYPE>)'" cannot be referenced from a static context"
I know it has been answered on other threads but all those answers don't solve my problem.
thanks in advance.
The compiler tell me
**
Error:(22, 54) java: non-static method <ELEMENT_TYPE>of(java.util.Collection<ELEMENT_TYPE>) cannot be referenced from a static context
Error:(31, 62) java: non-static method <ELEMENT_TYPE>of(java.util.Collection<ELEMENT_TYPE>) cannot be referenced from a static context
Error:(22, 63) java: cannot find symbol
symbol: method map(this::mapper)
location: interface java.util.Collection
Error:(31, 71) java: cannot find symbol
symbol: method toMap((it)->it.s[...]0, 2))
location: interface java.util.Collection
Error:(40, 64) java: cannot find symbol
symbol: method toSet()
location: interface java.util.Collection
Error:(40, 55) java: non-static method <ELEMENT_TYPE>of(java.util.Collection<ELEMENT_TYPE>) cannot be referenced from a static context
**
I precise that i don't have the right to edit the test file
Edit:
I rewrite switch to:
static <ELEMENT_TYPE> ExtendedCollection<ELEMENT_TYPE> of(Collection<ELEMENT_TYPE> list)
{
ExtendedCollection<ELEMENT_TYPE> c = new Collection<ELEMENT_TYPE>();
list.forEach(e -> c.add(e));
return (ExtendedCollection<ELEMENT_TYPE>) c;
}
and it almost works now I don't know how to instantiate an Extended collection as it is an interface