Does Java read integers in little endian or big endian? (#14381)

* Does Java read integers in little endian or big endian?

* Does Java read integers in little endian or big endian?
This commit is contained in:
Michael Olayemi 2023-07-13 01:05:34 +00:00 committed by GitHub
parent 0c195ad60b
commit 8333346c43
1 changed files with 17 additions and 0 deletions

View File

@ -0,0 +1,17 @@
package com.baeldung.endianness;
import java.nio.ByteBuffer;
public class Endianness {
public static void main(String[] args) {
int value = 123456789;
byte[] bytes = ByteBuffer.allocate(4)
.putInt(value)
.array();
for (byte b : bytes) {
System.out.format("0x%x ", b);
}
}
}