Type safe collection subtract
Posted on 2011-09-16
Collection<String> result = CollectionUtils.subtract(List1, List2);
I get the following warning for above code:
Type safety: The expression of type Collection needs unchecked conversion to conform to Collection<String>
How can I make this line of code type safe?
What would be the correct syntax to call an object's static function, and give that object a specific template type?
List1 and List2 are of type Set<String>
Set<String> List1 = new HashSet<String>();
Set<String> List2 = new HashSet<String>();