Answers for "collection coding interview questions"

0

collection coding interview questions

import java.util.*;
public class ArrayListContainsExample {
    public static void main(String args[]) {
        // initialize ArrayList  
        ArrayList<Integer> al = new ArrayList<Integer>();
        // add elements to ArrayList object
        al.add(3);
        al.add(17);
        al.add(6);
        al.add(9);
        al.add(7);
        // check if ArrayList contains element
        if (al.contains(7)) {
            System.out.println("7 was found in the list");
        } else {
            System.out.println("7 was not found in the list");
        }
    }
}
Posted by: Guest on November-26-2020

Code answers related to "collection coding interview questions"

Browse Popular Code Answers by Language