Java ArrayBlockingQueue remainingCapacity() Method

The remainingCapacity() method of Java ArrayBlockingQueue class returns the capacity of the elements that this queue can accept without blocking.

Syntax:

Parameters:

NA

Specified By:

The remainingCapacity () method of ArrayBlockingQueue class is specified by remainingCapacity in interface BlockingQueue.

Return Value:

The remainingCapacity () method returns the remaining capacity of the queue.

Example 1

Output:

Queue : [1, 2, 3, 4, 5, 6]
Remaining capacity of the queue = 4

Example 2

Output:

Register your name quickly in JavaTpoint.
As only 7 seats are left

Example 3

Output:

Enter capacity : 5
Remaining capacity : 5
Element : 56

Remaining capacity : 4
Element : 78

Remaining capacity : 3
Element : 55

Remaining capacity : 2
Element : 9

Remaining capacity : 1
Element : 76

Queue = [56, 78, 55, 9, 76]