Example usage for java.util.concurrent ArrayBlockingQueue toArray

List of usage examples for java.util.concurrent ArrayBlockingQueue toArray

Introduction

In this page you can find the example usage for java.util.concurrent ArrayBlockingQueue toArray.

Prototype

@SuppressWarnings("unchecked")
public <T> T[] toArray(T[] a) 

Source Link

Document

Returns an array containing all of the elements in this queue, in proper sequence; the runtime type of the returned array is that of the specified array.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    int capacity = 10;
    ArrayBlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(capacity);

    for (int i = 0; i < 10; i++) {
        queue.add(i);/*w  ww .  ja  va2 s  .c o  m*/
    }

    System.out.println(Arrays.toString(queue.toArray(new Integer[queue.size()])));
}