Little endian and big endian are ways to store multi-byte data types. Little endian store the last byte of binary representation of the multibyte store first. The big endian store first byte of binary representation of the multibyte store first.
Write a program to find whether machine is big endian or little endian.
source Code
package com.dsacode.Algorithm.bit; import java.nio.ByteOrder; public class BigendianLittleendian { public static void main(String[] args) { if (ByteOrder.nativeOrder().equals(ByteOrder.BIG_ENDIAN)) { System.out.println("Big-endian"); } else { System.out.println("Little-endian"); } } }
Output
Little-endian
Algorithm Explanation
![]() | Use API or bite conversation to find the order. |
![]() | Based on the return value, display little endian or big endian information. |