3:13 pm - Thursday December 17, 4167

check whether a value is present in LinkedList boolean contains(Object value)

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

BACK

          This tutorial explains how  to check whether a value is present in LinkedList using

boolean contains() method.The specific elements is matched with collection elements

it matches means it returns  true.

Example


import java.util.LinkedList;
public class CheckContains
{
public static void main(String a[])
{
   LinkedList arr = new LinkedList();
   arr.add("First");
   arr.add("Second");
   List list = new LinkedList();
   list.add("First");
   System.out.println("LinkedList contains list elements: "+arr.contains("Second"));
   System.out.println("LinkedList contains list elements: "+list.contains("Second"));
 }
}

Output

          LinkedList contains list elements: true

          LinkedList contains list elements: false

BACK

Filed in: Java Examples

Comments are closed.