Saturday, 12 April 2014

size : Number Of Elements in Deque

public int size()
Returns the number of elements in this deque.
import java.util.*;
import java.util.concurrent.LinkedBlockingDeque;

class DequeSize{
  public static void main(String args[]){
    Deque<Integer> myDeque = new LinkedBlockingDeque<Integer> (5);
  
  myDeque.add(10);
  myDeque.add(20);
  myDeque.add(30);
  myDeque.add(40);
  myDeque.add(10);
  
  System.out.println("Elements in the Deque are "+ myDeque);
  System.out.println("Number Of Elements in Deque " + myDeque.size());

 }
}

Output
Elements in the Deque are [10, 20, 30, 40, 10]
Number Of Elements in Deque 5

Prevoius                                                 Next                                                 Home

No comments:

Post a Comment