package arraylisttesting; import java.util.ArrayList; import java.util.Arrays; public class DoesItemExist { public static ArrayList> temp = new ArrayList>(); public static boolean checkExist(String num){ for(ArrayList a : temp){ if(a.get(0).equals(num)){ return true; } } return false; } public static void main(String[] args) { ArrayList al = new ArrayList<>( Arrays.asList( "5", "a", "b", "c" ) ); temp.add(al); ArrayList al2 = new ArrayList<>( Arrays.asList( "6", "z", "y", "x" ) ); temp.add(al2); System.out.println(temp); System.out.println(); if(checkExist("3")) System.out.println("3 exist."); if(checkExist("5"))System.out.println("5 exist."); } }