List <T> cannot contain objects of type Object
Short :
Is it possible to have a class that is not a child Object?
Long
I work with List<T>, which contains interface implementations ( Operation):
public class OperationQueue<T extends Operation> {
private final List<T> mQueue = new ArrayList<>();
...
}
When I look at this list in a loop, I mark each completed operation as null, because I have to maintain the same size, and I cannot use an iterator (it throws ConcurrentModificationException):
for (int i = 0; i < mQueue.size() && !mState.equals(State.PAUSED); i++) {
mOperation = mQueue.get(i);
if (mOperation != null) {
mOperation.run();
}
mQueue.set(i, null);
}
When I pause or end a queue, I use:
mQueue.removeAll(Collections.singleton(null));
And Android Studio warns me:
'List<T>' may not contain type objects of type 'Object'
How is this possible? I thought everything is a child Object?
Any help would be greatly appreciated.
+4
3