Set<Object> removedObjs = new HashSet<>();
List<? extends MyEntity> delObjs = (List<? extends MyEntity>) new ArrayList<>(removedObjs);
MyEntity is marker interface.
Above code is working fine in java-7(java version "1.7.0_91", to be precise) but not in java-8(java version "1.8.0_77")
In Java8, I am getting the following exception:
incompatible types: ArrayList<Object> cannot be converted to List< ? extends MyEntity>
<>you should get just a warning. If it doesn't work in Java 8, then it probably shouldn't have worked in Java 7.removedObjs.add("42");between the two lines to see why.