I've looked on here and what i got did not really work. Here is the code which runs but it's not doing what i expect it to do
package bcu.gui;
import java.util.ArrayList;
import java.util.Arrays;
public class compare {
private static ArrayList<String> list = new ArrayList<String>();
public static void main(String[] args) {
list.add("Paul");
list.add("James");
System.out.println(list); // Printing out the list
// If the list containsthe name Paul, then print this. It still doesn't print even though paul is in the list
if(Arrays.asList(list).contains("Paul")){
System.out.println("Yes it does");
}
}
}
Arrays.asList(list)?listis already aList...?Arrays.asList(list)creates an object of typeArrayList<ArrayList<String>>if(Arrays.asList(list).contains("Paul")){should beif(list.contains("Paul")){