Welcome Message

Hi, welcome to my website. This is a place where you can get all the questions, puzzles, algorithms asked in interviews and their solutions. Feel free to contact me if you have any queries / suggestions and please leave your valuable comments.. Thanks for visiting -Pragya.

Showing posts with label ByteOrder. Show all posts
Showing posts with label ByteOrder. Show all posts

January 3, 2010

Prog to find if a machine is Little Endian or Big Endian

import java.nio.ByteOrder;

public class FindEndianness {

public static void main(String[] args) {
ByteOrder b = ByteOrder.nativeOrder();
if(b.equals(ByteOrder.BIG_ENDIAN)){
System.out.println("Big Endian");
}else if(b.equals(ByteOrder.LITTLE_ENDIAN)){
System.out.println("Little Endian");
}
}

}