Also this is pretty dumb. Generics work by generating casts at compile time. An empty list is type-agnostic because it's empty and throws an exception when you try adding anything to it. Yet Idea shows this warning, implying there's something fundamentally wrong with your code.