I'm trying to build a simple interface using generics, here's the code I'm trying to use:
public interface MyInterface<T>
{
public ArrayList<T> items;
//...
}
However I'm getting an error about accessing static variable T from a non static context, etc. How can I accomplish what I'm trying to do? This is how I envision using a class which implements this interface:
MyInterface<SomeObject> foo = new MyInterfaceImpl<>();
for (SomeObject bar: foo.items)
{
bar.someMethod();
}
Is this possible to specify via interfaces?