I have a criteria that is returning a list of strings List<String>
.
I have following in the method
return criteria.list();
But the code shows
Type safety: Unchecked cast from List to List<String>
To avoid adding @SuppressWarnings("unchecked")
and to make sure the types are safely converted (not sure if I should really do it), I read this question and tried to add the solution to my code
return Collections.checkedList(criteria.list(),List<String>);
but it shows another error as following:
Multiple markers at this line
- Type safety: Unchecked cast from List to List<String>
- Syntax error on token ">", Expression expected after this
token
- I do not know if I should really use Collections.checkedList
- If I should use it, then how to use it?
Thanks