Friday, April 3, 2026
HomeLanguagesJavaShortBuffer order() Method in Java with Examples

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:




// 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
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32512 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6885 POSTS0 COMMENTS
Nicole Veronica
12006 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12100 POSTS0 COMMENTS
Shaida Kate Naidoo
7015 POSTS0 COMMENTS
Ted Musemwa
7259 POSTS0 COMMENTS
Thapelo Manthata
6971 POSTS0 COMMENTS
Umr Jansen
6960 POSTS0 COMMENTS