-1
public static void main (){
    byte[] a = get();
    byte[] b = {1,2,3,4};

    System.arraycopy(a, 0, b, 2, 2);
    System.arraycopy(b, 0, a, 0, 2);
}

public static byte[] get(){
    byte c={5,6}; // byte c= new byte[2];...
    return c;
}

My question is: what the difference between returning byte c={5,6} and byte c=new byte[2]; c[0]=5;c[1]=6;?

Yatin
  • 2,348
  • 6
  • 20
  • 38

1 Answers1

0

c={5,6} initializes the array with an array of size 2, and values "5" and "6".
c=new byte[2] initializes the array with an array of size 2, and values 0 and 0.

Yoav Gur
  • 1,176
  • 8
  • 13