Advertisement
killerbng

working test

Sep 15th, 2016
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.05 KB | None | 0 0
  1. package arraylisttesting;
  2. import java.util.ArrayList;
  3. import java.util.Arrays;
  4.  
  5. public class DoesItemExist {
  6.    
  7.     public static ArrayList<ArrayList<String>> temp = new ArrayList<ArrayList<String>>();
  8.    
  9.     public static boolean checkExist(String num){
  10.         for(ArrayList<String> a : temp){
  11.             if(a.get(0).equals(num)){
  12.                 return true;
  13.             }
  14.         }
  15.         return false;
  16.     }
  17.    
  18.     public static void main(String[] args) {
  19.         ArrayList<String> al = new ArrayList<>(
  20.             Arrays.asList(
  21.                     "5", "a", "b", "c"
  22.             )
  23.         );        
  24.         temp.add(al);
  25.         ArrayList<String> al2 = new ArrayList<>(
  26.             Arrays.asList(
  27.                     "6", "z", "y", "x"
  28.             )
  29.         );        
  30.         temp.add(al2);
  31.        
  32.         System.out.println(temp);
  33.         System.out.println();
  34.        
  35.         if(checkExist("3")) System.out.println("3 exist.");
  36.        
  37.         if(checkExist("5"))System.out.println("5 exist.");  
  38.     }
  39.    
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement