代码有什么问题?
package com.imooc;
public class Convert {
public static byte[] int2Bytes(int id){
byte[] arr=new byte[4];
for(int i=0;i<arr.length;i++){
arr[i]=(byte)((int)(id>>0*8) & 0xff);
}
return arr;
}
public static int bytes2Int(byte[] arr){
int result=0;
for(int i=0;i<arr.length;i++){
result += (int)((arr[i] & 0xff)<<i*8);
}
return result;
}
public static void main(String[] args) {
byte[] arr=Convert.int2Bytes(8143);
System.out.println(arr[0]+","+arr[1]+","+arr[2]+","+arr[3]);
System.out.println(Convert.bytes2Int(arr));
}
}