ShortBuffer order() Method in Java with Examples

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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());
    }
}

chevron_right


Output:

LITTLE_ENDIAN


My Personal Notes arrow_drop_up

Budding Web DeveloperKeen learnerAverage CoderDancer&Social Activist

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.