LinkedTransferQueue remainingCapacity() method in Java with Examples
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
import java.util.concurrent.LinkedTransferQueue;
class GFG {
public static void main(String args[])
{
LinkedTransferQueue<Integer> LTQ
= new LinkedTransferQueue<Integer>();
LTQ.add( 7855642 );
LTQ.add( 35658786 );
LTQ.add( 5278367 );
LTQ.add( 74381793 );
System.out.println("Linked Transfer Queue1: "
+ LTQ);
System.out.println(LTQ.remainingCapacity());
}
}
|
Output:
Linked Transfer Queue1: [7855642, 35658786, 5278367, 74381793]
2147483647
Example 2:
Java
import java.util.concurrent.LinkedTransferQueue;
class GFG {
public static void main(String args[])
{
LinkedTransferQueue<String> LTQ
= new LinkedTransferQueue<String>();
LTQ.add("Geeks");
LTQ.add("For");
LTQ.add("Geeks");
LTQ.add("GeeksForGeeks");
System.out.println("Linked Transfer Queue1: "
+ LTQ);
System.out.println(LTQ.remainingCapacity());
}
}
|
Output:
Linked Transfer Queue1: [Geeks, For, Geeks, GeeksForGeeks]
2147483647
Share your thoughts in the comments
Please Login to comment...