當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


Java LinkedTransferQueue remainingCapacity()用法及代碼示例


Java.util.concurrent.LinkedTransferQueue.remainingCapacity():方法始終返回Integer.MAX_VALUE,因為這種隊列不受容量限製。

句法

public int remainingCapacity()

參數:此方法不接受任何參數。


返回值:此方法僅返回一個值,即Integer.MAX_VALUE。

以下示例說明了LinkedTransferQueue.remainingCapacity()方法:

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

示例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()); 
    } 
}
輸出:
Linked Transfer Queue1: [Geeks, For, Geeks, GeeksForGeeks]
2147483647


相關用法


注:本文由純淨天空篩選整理自psil123大神的英文原創作品 LinkedTransferQueue remainingCapacity() method in Java with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。