幫忙看一下代碼的錯誤,謝謝
public class Coner1 {
public static byte[]int2bytes(int id){
byte[] arr=new byte[4];//創(chuàng)建一個數(shù)組,長度為四
arr[0]=(byte)((int)id>>0*8 && 0xff);//0xff報錯Oxff cannot be resolved to a variable
arr[1]=(byte)((int)id>>1*8 && 0xff);
arr[2]=(byte)((int)id>>2*8 && 0xff);
arr[3]=(byte)((int)id>>3*8 && 0xff);
return arr;?
}
public static void main(String[] args) {
byte[]arr=Coner1.int2bytes(8143);
System.out.println(arr[0]+","arr[1]+","arr[2]+","arr[3]);//arr報錯
}
}
2016-06-17
public class Coner1 {
public static byte[]int2bytes(int id){
byte[] arr=new byte[4];//創(chuàng)建一個數(shù)組,長度為四
arr[0]=(byte)((int)id>>0*8 & 0xff);//0xff報錯Oxff cannot be resolved to a variable
arr[1]=(byte)((int)id>>1*8 & 0xff);
arr[2]=(byte)((int)id>>2*8 & 0xff);
arr[3]=(byte)((int)id>>3*8 & 0xff);
return arr;?
}
public static void main(String[] args) {
byte[]arr=Coner1.int2bytes(8143);
System.out.println(arr[0]+","+arr[1]+","+arr[2]+","+arr[3]);//arr報錯
}
}
2016-06-17
不知道