Skip to content
Related Articles

Related Articles

Improve Article

LinkedTransferQueue remainingCapacity() method in Java with Examples

  • Last Updated : 27 Dec, 2018

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

Syntax

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

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:




// 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());
    }
}
Output:
Linked Transfer Queue1: [7855642, 35658786, 5278367, 74381793]
2147483647

Example 2:




// 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());
    }
}
Output:
Linked Transfer Queue1: [Geeks, For, Geeks, GeeksForGeeks]
2147483647



My Personal Notes arrow_drop_up
Recommended Articles
Page :