1:40 pm - Tuesday August 21, 2018

ArrayList Example Program for contains(Object o)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
/**
*@author :CandidJava.com
*@descriptions : This program explain the function and use of
boolean  contains(Object o).It is used to check whether given element exist in the List or not
*/
import java.io.*;
import java.util.*;
public class ArrayListContains
{
public static void main(String arg[])throws Exception
{
ArrayList E=new ArrayList();//to create object for ArrayList class
E.add(12);//to add an element in arrayList
E.add(10);//to add an element in arrayList
E.add(6);//to add an element in arrayList
Boolean b=new Boolean (E.contains(6));//to check whether given element exist in the List or not
System.out.println(E);
System.out.println(b);
}
}

Output:
[12,10,6]
True

BACK

Filed in: Z-A All Java Codes

Comments are closed.