java.nio.DoubleBuffer類的order()方法用於獲取此DoubleBuffe實例的ByteOrder。
用法:
public abstract ByteOrder order()
返回值:此方法返回此緩衝區的字節順序。
下麵是說明order()方法的示例:
範例1:
// Java program to demonstrate
// order() method
import java.nio.*;
import java.util.*;
public class GFG {
public static void main(String[] args)
{
// creating object of DoubleBuffer
// and allocating size capacity
DoubleBuffer db
= DoubleBuffer.allocate(4);
// put the double value
// in the Doublebuffer
db.put(10.5)
.put(20.5)
.put(30.5)
.put(40.5);
// rewind the Doublebuffer
db.rewind();
// Retrive the ByteOrder
// using order() method
ByteOrder order = db.order();
// print the double buffer and order
System.out.println("DoubleBuffer is:"
+ Arrays.toString(
db.array())
+ "\nOrder:"
+ order);
}
}
輸出:
DoubleBuffer is:[10.5, 20.5, 30.5, 40.5] Order:LITTLE_ENDIAN
範例2:
// Java program to demonstrate
// order() method
import java.nio.*;
import java.util.*;
public class GFG {
public static void main(String[] args)
{
// creating object of DoubleBuffer
// and allocating size capacity
DoubleBuffer db
= DoubleBuffer.allocate(4);
// Retrive the ByteOrder
// using order() method
ByteOrder order = db.order();
// print the double buffer and order
System.out.println("DoubleBuffer is:"
+ Arrays.toString(
db.array())
+ "\nOrder:"
+ order);
}
}
輸出:
DoubleBuffer is:[0.0, 0.0, 0.0, 0.0] Order:LITTLE_ENDIAN
參考: https://docs.oracle.com/javase/9/docs/api/java/nio/DoubleBuffer.html#order-
相關用法
- Java DoubleBuffer get()用法及代碼示例
- Java DoubleBuffer put()方法用法及代碼示例
- Java DoubleBuffer limit()用法及代碼示例
- Java DoubleBuffer reset()用法及代碼示例
- Java DoubleBuffer clear()用法及代碼示例
- Java DoubleBuffer flip()用法及代碼示例
- Java DoubleBuffer mark()用法及代碼示例
- Java CharBuffer order()用法及代碼示例
- Java DoubleBuffer allocate()用法及代碼示例
- Java DoubleBuffer duplicate()用法及代碼示例
- Java DoubleBuffer compact()用法及代碼示例
- Java DoubleBuffer hasArray()用法及代碼示例
- Java DoubleBuffer rewind()用法及代碼示例
- Java DoubleBuffer asReadOnlyBuffer()用法及代碼示例
- Java DoubleBuffer equals()用法及代碼示例
注:本文由純淨天空篩選整理自RohitPrasad3大神的英文原創作品 DoubleBuffer order() methods in Java with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。