I want a list of things, and then I want to test the list to see if an item exists:
Here is my example snippet:
String[] handToolArray = {"pliers", "screwdriver", "tape measure"};
List<String> handToolList = new ArrayList<String>( Arrays.asList(handToolArray));
if (handToolList.contains("pliers")){
System.out.println("I have pliers");
} else {
System.out.println("I don't have pliers");
}
In the second line, the Arrays.asList(handToolArray) generates:
"Type safety: The expression of type List needs unchecked conversion to conform to Collection<? extends String>"
Question: Is there a better way to create then query the list, that is succinct and does not require unchecked warnings to be suppressed?