Java.util.concurrent.atomic.AtomicLongArray.length()是Java中的內置方法,該方法返回AtomicLongArray的長度。此方法不接受任何參數,並返回int類型的AtomicLongArray的長度。
用法:
public final int length()
參數:該函數不接受任何參數。
返回值:該函數返回AtomicLongArray的長度。
以下示例程序旨在說明上述方法:
示例1:
// Java program that demonstrates
// the length() function
import java.util.concurrent.atomic.AtomicLongArray;
public class GFG {
public static void main(String args[])
{
// Initializing an array
long a[] = { 11, 12, 13, 14, 15 };
// Initializing an AtomicLongArray with array a
AtomicLongArray arr = new AtomicLongArray(a);
// Displaying the length of the AtomicLongArray
System.out.println("The length of the array : "
+ arr.length());
}
}
輸出:
The length of the array : 5
示例2:
// Java program that demonstrates
// the length() function
import java.util.concurrent.atomic.AtomicLongArray;
public class GFG {
public static void main(String args[])
{
// Initializing an array
long a[] = { 11, 12, 13, 14, 15, 16, 17 };
// Initializing an AtomicLongArray with array a
AtomicLongArray arr = new AtomicLongArray(a);
// Displaying the length of the AtomicLongArray
System.out.println("The length of the array : "
+ arr.length());
}
}
輸出:
The length of the array : 7
參考:
https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicLongArray.html#length–
相關用法
- Java AtomicLongArray get()用法及代碼示例
- Java AtomicLongArray set()用法及代碼示例
- Java AtomicLongArray lazySet()用法及代碼示例
- Java AtomicLongArray addAndGet()用法及代碼示例
- Java AtomicLongArray toString()用法及代碼示例
- Java AtomicLongArray updateAndGet()用法及代碼示例
- Java AtomicLongArray getAndUpdate()用法及代碼示例
- Java AtomicLongArray decrementAndGet()用法及代碼示例
- Java AtomicLongArray getAndIncrement()用法及代碼示例
- Java AtomicLongArray getAndSet()用法及代碼示例
- Java AtomicLongArray getAndAccumulate()用法及代碼示例
- Java AtomicLongArray getAndDecrement()用法及代碼示例
- Java AtomicLongArray getAndAdd()用法及代碼示例
- Java AtomicLongArray incrementAndGet()用法及代碼示例
- Java AtomicLongArray accumulateAndGet()用法及代碼示例
注:本文由純淨天空篩選整理自rupesh_rao大神的英文原創作品 AtomicLongArray length() method in Java with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。