12:52 am - Thursday July 27, 2017

check whether all values are present in LinkedList boolean containsAll(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 all values are  present in LinkedList using boolean

containsAll() method. To check the arr contains all elements which are  list contains.

Example

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

Output

          LinkedList contains list elements: true

          LinkedList contains list elements: false

         LinkedList contains list elements: false

BACK

Filed in: Java Examples

Comments are closed.