byte[0]一个值
byte[1]一个值
byte[2]和byte[3]中要存一个值怎样这一个值存到数组的2个下标中呢?

解决方案 »

  1.   

    参考下面:
    String a = "测";
    byte[] b = a.getBytes();
    for(int i = 0 ; i < b.length;i++){
     byte[2+i] = b[i];
    }
      

  2.   


    public class A {
    public static void main(String[] args) {
    byte[] b = new byte[8];
    for (int i = 0; i < b.length / 2; i++) {
    b[2 * i + 1] = b[2 * i] = (byte) (i * i);
    }
    for (int i = 0; i < b.length; i++)
    System.out.println(b[i]);
    }
    }