I want to be sure if the object I get is a List of Strings. Here's my code:
Object obj = plugin.getConfig().get("groups");
if(obj instanceof List<?>){ // Is the Object a List ?
List<?> list = (List<?>) obj;
if(list.get(0) instanceof String){ // Does the List contain Strings ?
List<String> groupList = (List<String>) list;
}
}
But Eclipse says that the last cast on line 5 isn't safe:
Type safety: Unchecked cast from List<capture#3-of ?> to List<String>
How can I fix that? I've also tried
List<String> groupList = (List<String>) obj;
...but I still get the same error (basically).