0

How can I detect endianness on a system in java?I dont want to use inbuilt methods as its a interview question. Also how to convert big to small and vice versa?

Am looking for ans using Java and not C/C++. I had found such links Detecting endianness programmatically in a C++ program

Community
  • 1
  • 1
user93796
  • 18,749
  • 31
  • 94
  • 150
  • 4
    If an interviewer wants you to program in Java without using any inbuilt methods then you probably want to call them on that. :) – Chris Dec 02 '11 at 17:39
  • If for a minute I put aside that it's just a silly interview question, why would anyone want to know the endianness in Java? It isn't ever going to matter, is it? – harold Dec 02 '11 at 17:57

1 Answers1

5

Doesn't java.nio.ByteOrder.nativeOrder() give it to you?

Check the source of that.

CPerkins
  • 8,968
  • 3
  • 34
  • 47