# ArrayBlockingQueue remainingCapacity() Method in Java

The remainingCapacity() method of the ArrayBlockingQueue class in Java is used to return the number of additional elements that the queue can adopt without blocking.

The syntax is as follows

int remainingCapacity()

To work with ArrayBlockingQueue class, you need to import the following package

import java.util.concurrent.ArrayBlockingQueue;

The following is an example to implement remainingCapacity() method of Java ArrayBlockingQueue class

## Example

Live Demo

import java.util.concurrent.ArrayBlockingQueue;
public class Demo {
public static void main(String[] args) throws InterruptedException {
ArrayBlockingQueue<Integer> q = new ArrayBlockingQueue<Integer>(10);
System.out.println("ArrayBlockingQueue = " + q);
System.out.println("ArrayBlockingQueue Remaining Capacity = " + q.remainingCapacity());
System.out.println("ArrayBlockingQueue = " + q);
System.out.println("ArrayBlockingQueue Remaining Capacity = " + q.remainingCapacity());
System.out.println("ArrayBlockingQueue = " + q);
System.out.println("ArrayBlockingQueue Remaining Capacity = " + q.remainingCapacity());
}
}

## Output

ArrayBlockingQueue = [120, 400, 450, 500]
ArrayBlockingQueue Remaining Capacity = 6
ArrayBlockingQueue = [120, 400, 450, 500, 620, 700]
ArrayBlockingQueue Remaining Capacity = 4
ArrayBlockingQueue = [120, 400, 450, 500, 620, 700, 820, 900, 950]
ArrayBlockingQueue Remaining Capacity = 1