LinkedTransferQueue remainingCapacity() method in Java with Examples

The Java.util.concurrent.LinkedTransferQueue.remainingCapacity(): method always returns Integer.MAX_VALUE as this kind of queue is not capacity constrained.

Syntax

public int remainingCapacity()

Parameters: This method does not take in any parameters.



Returns: This method returns only one value i.e. Integer.MAX_VALUE.

Below examples illustrates the LinkedTransferQueue.remainingCapacity() method:

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java program to illustrate
// LinkedTransferQueue.remainingCapacity() method
  
import java.util.concurrent.LinkedTransferQueue;
  
class GFG {
    public static void main(String args[])
    {
  
        // create object of LinkedTransferQueue
        // using LinkedTransferQueue() constructor
        LinkedTransferQueue<Integer> LTQ
            = new LinkedTransferQueue<Integer>();
  
        // Add numbers to end of LinkedTransferQueue
        LTQ.add(7855642);
        LTQ.add(35658786);
        LTQ.add(5278367);
        LTQ.add(74381793);
  
        // print Dequee
        System.out.println("Linked Transfer Queue1: "
                           + LTQ);
  
        // print the remaining capacity
        // using remainingCapacity() method
        System.out.println(LTQ.remainingCapacity());
    }
}

chevron_right


Output:

Linked Transfer Queue1: [7855642, 35658786, 5278367, 74381793]
2147483647

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java program to illustrate
// LinkedTransferQueue.remainingCapacity() method
  
import java.util.concurrent.LinkedTransferQueue;
  
class GFG {
    public static void main(String args[])
    {
  
        // create object of LinkedTransferQueue
        // using LinkedTransferQueue() constructor
        LinkedTransferQueue<String> LTQ
            = new LinkedTransferQueue<String>();
  
        // Add numbers to end of LinkedTransferQueue
        LTQ.add("Geeks");
        LTQ.add("For");
        LTQ.add("Geeks");
        LTQ.add("GeeksForGeeks");
  
        // print Dequee
        System.out.println("Linked Transfer Queue1: "
                           + LTQ);
  
        // print the remaining capacity
        // using remainingCapacity() method
        System.out.println(LTQ.remainingCapacity());
    }
}

chevron_right


Output:

Linked Transfer Queue1: [Geeks, For, Geeks, GeeksForGeeks]
2147483647


My Personal Notes arrow_drop_up

Image
Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.