Skip to content
Related Articles

Related Articles

Improve Article

ShortBuffer order() Method in Java with Examples

  • Last Updated : 20 Sep, 2018

The order() method of java.nio.ShortBuffer is used to retrieve the buffer’s byte order.
The byte order of a short buffer created by allocation or by wrapping an existing short array is the native order of the underlying hardware. The byte order of a short buffer created as a view of a byte buffer is that of the byte buffer at the moment that the view is created.

Syntax:

public abstract ByteOrder order()

Return Value: The method returns the buffer’s byte order.

Below programs illustrate the use of order() method:

Program 1:




// Java program to demonstrate
// order() method
  
import java.nio.*;
import java.util.*;
  
public class GFG {
    public static void main(String[] args)
    {
  
        // creating short buffer
        ShortBuffer bb = ShortBuffer.allocate(7);
  
        bb.put((short)44);
  
        // using the order method
        System.out.println(bb.order());
    }
}
Output:
LITTLE_ENDIAN

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :