问题描述
- 请问下为什么最后的结果是这个值
-
public static Long bytes2long(byte[] b, int index) {
ByteBuffer buffer = ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN);
buffer.put(b, index, 8);
return buffer.getLong(0);
}public static void main(String[] args) {
String text = "11111111";
byte[] bytes = text.getBytes(Charset.forName("utf-8"));
for (int i = 0; i < bytes.length; i++) {
System.out.println(bytes[i]);
}
long result = bytes2long(bytes,0);
System.out.println(result);
}result;3544668469065756977
时间: 2024-11-22 20:50:17