Java.util.concurrent.atomic.AtomicLongArray.toString()是Java中的內置方法,該方法返回一個字符串,該字符串以文本形式表示AtomicLongArray的當前值。生成的字符串是簡潔易懂的表示形式,易於閱讀。它用於輕鬆地將內容AtomicLongArray打印為字符串對象。
用法:
public String toString()
參數:該函數不帶參數。
返回值:該函數返回AtomicLongArray當前值的字符串表示形式。
以下示例程序旨在說明上述方法:
示例1:
// Java program that demonstrates
// the toString() function
import java.util.concurrent.atomic.AtomicLongArray;
public class GFG {
public static void main(String args[])
{
// Initializing an array
long a[] = { 1, 2, 3, 4, 5 };
// Initializing an AtomicLongArray
// with array a
AtomicLongArray arr
= new AtomicLongArray(a);
// Displaying the AtomicLongArray
System.out.println("The array : "
+ arr);
// Displaying the string representation
// of AtomicLongArray
System.out.println("The string representation"
+ " of the array: "
+ arr.toString());
}
}
輸出:
The array : [1, 2, 3, 4, 5] The string representation of the array: [1, 2, 3, 4, 5]
示例2:
// Java program that demonstrates
// the toString() 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 AtomicLongArray
System.out.println("The array : " + arr);
// Displaying the string representation
// of AtomicLongArray
System.out.println("The string representation"
+ " of the array: "
+ arr.toString());
}
}
輸出:
The array : [11, 12, 13, 14, 15] The string representation of the array: [11, 12, 13, 14, 15]
參考: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicLongArray.html#toString–
相關用法
- Java AtomicLongArray set()用法及代碼示例
- Java AtomicLongArray get()用法及代碼示例
- Java AtomicLongArray compareAndSet()用法及代碼示例
- Java AtomicLongArray decrementAndGet()用法及代碼示例
- Java AtomicLongArray addAndGet()用法及代碼示例
- Java AtomicLongArray accumulateAndGet()用法及代碼示例
- Java AtomicLongArray getAndAdd()用法及代碼示例
- Java AtomicLongArray lazySet()用法及代碼示例
- Java AtomicLongArray getAndDecrement()用法及代碼示例
- Java AtomicLongArray getAndAccumulate()用法及代碼示例
- Java AtomicLongArray getAndUpdate()用法及代碼示例
- Java AtomicLongArray getAndIncrement()用法及代碼示例
- Java AtomicLongArray incrementAndGet()用法及代碼示例
- Java AtomicLongArray length()用法及代碼示例
- Java AtomicLongArray updateAndGet()用法及代碼示例
注:本文由純淨天空篩選整理自rupesh_rao大神的英文原創作品 AtomicLongArray toString() method in Java with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。