I have the following class & interface defined:
public interface A {
}
public class B implements A {
}
I have a List
of <
You can just use type erasure if you know the operation is safe. This produces a warning which you can turn off using @SuppressWarnings
List<A> listA = (List) listB;
The reason the compiler has difficulty with a plain cast is that you can now add a class C which also implements A. Except your original list has been altered and now contains a C even though you have specified that it shouldn't.