Skip to content
Related Articles

Related Articles

LinkedTransferQueue remainingCapacity() method in Java with Examples

View Discussion
Improve Article
Save Article
  • Last Updated : 04 Aug, 2022

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: 

Java




// 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 Deque
        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




// 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 Deque
        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 :

Start Your Coding Journey Now!