Java ArrayBlockingQueue.toArray()
Syntax
ArrayBlockingQueue.toArray() has the following syntax.
public Object [] toArray()
Example
In the following code shows how to use ArrayBlockingQueue.toArray() method.
import java.util.Arrays;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
//ww w .j ava2s. c om
public class Main {
public static void main(String[] argv) throws Exception {
int capacity = 10;
BlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(capacity);
for (int i = 0; i < 10; i++) {
queue.add(i);
}
System.out.println(Arrays.toString(queue.toArray()));
}
}
The code above generates the following result.