简体   繁体   English

Java 返回字节数组

[英]Java return byte array

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;我的问题是:返回byte c={5,6}byte c=new byte[2]; c[0]=5;c[1]=6;什么区别byte c=new byte[2]; c[0]=5;c[1]=6; byte c=new byte[2]; c[0]=5;c[1]=6; ? ?

c={5,6} initializes the array with an array of size 2, and values "5" and "6". c={5,6}用大小为 2 的数组初始化数组,值为“5”和“6”。
c=new byte[2] initializes the array with an array of size 2, and values 0 and 0 . c=new byte[2]使用大小为 2 的数组初始化数组,值为00

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM