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:
parent
0c195ad60b
commit
8333346c43
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue