Monday, 17 November 2014

Java : Collection Framework : Deque (Contains method)


Click here to watch in Youtube : https://www.youtube.com/watch?v=l3QDQAZ3zQE&list=UUhwKlOVR041tngjerWxVccw

DequeExample.java
import java.util.Deque;
import java.util.LinkedList;

/*
 *  Example of contains(Object o) method.
 */
public class DequeExample
{

    public static void main(String[] args)
    {
        Deque<Integer> deque = new LinkedList<Integer>();
        deque.add(200);
        deque.add(300);
        deque.add(200);

        System.out.println("deque : " + deque + "\n");

        /*
         * Returns true if this deque contains the specified element.
         */
        boolean isExist = deque.contains(300);
        System.out.println("is 300 Exist :  " + isExist);

        isExist = deque.contains(10000);
        System.out.println("is 10000 Exist : " + isExist);

    }

}




Output
deque : [200, 300, 200]

is 300 Exist :  true
is 10000 Exist : false

To Download DequeDemoContains Project Click the below link
https://sites.google.com/site/javaee4321/java-collections/DequeDemoContains.zip?attredirects=0&d=1

See also:

  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • No comments:

    Post a Comment