Showing posts with label JAVA. Show all posts
Showing posts with label JAVA. Show all posts

Varargs Example in JAVA

import java.util.*;
import java.io.*;
class T
{
static void display(Object ... val)
{
for(Object o:val)
System.out.println(o);
}

public static void main(String args[])throws Exception
{
display();
display(45);
display(10,20.2f,30,"Hello");
display(45,43,67,23);
}
}

JAVA is following Big Endian

How can we Say that JAVA (JVM ) is following Big Endian Byte Ordering?

[* For Intel x86/x86_64 ]


class C1
{

public static void main(String args[])
{
int no=Integer.parseInt(args[0]);

Byte barray[] = new Byte[4];

barray[0] = (byte) ((no >> 24) & 0xFF);
barray[1] = (byte) ((no >> 16) & 0xFF);
barray[2] = (byte) ((no >> 8) & 0xFF);
barray[3] = (byte) (no & 0xFF);


for(int i=0;i<4;i++)
{
System.out.println(barray[i]);
}

}
}