先把两个变量加起来赋给第三个变量,然后用类型变换把地三个变量转换为byte型的,
不过有可能会溢出,楼主要注意

解决方案 »

  1.   

    那已经是byte型的了,怎么合并?我还是不太明白。能说详细一点吗?
      

  2.   

    搂住的意思是不是两个byte型数组,想合并成一个数组?就像:
    byte a[] = new byte[10]
    byte b[] = new byte[20]
    byte c[] 由a和b组成的含有30个元素的数组?
      

  3.   

    对。就是这个意思。同意chinson(鹤巢)
      

  4.   

    byte c = new byte[a.length + b.length];
    然后做for循环取值,并且再给c就可以了
      

  5.   

    byte c[] = (new String(a)+new String(b)).getBytes();
      

  6.   

    同意楼上,用arraycopy也挺方便的
      

  7.   

    public class ByteTest { public static void main(String[] args) {
    byte[] a={'a','b','c'};
    byte[] b={'1','2','3'};
    byte[] c=(new String(a)+ new String(b)).getBytes() ;
    for (int i=0; i<c.length; i++){
    System.out.println((char)c[i]); 
    }
    }
    }
      

  8.   

    for (int i=a.length,j=0; i<=a.length+b.length; i++,j++){
         c[i]=b[j];

      

  9.   

    byte c[] = new byte[a.lenght + b.lenght];
    for (int i=0; i<a.length; i++){
         c[i]=a[i];

    for (int i=a.length,j=0; i<a.length+b.length; i++,j++){
         c[i]=b[j];

      

  10.   

    byte c[] = new byte[a.lenght + b.lenght];
    System.arraycopy(a,0,c,0,a.length);
    System.arraycopy(b,0,c,a.length-1,b.length);