package javatuning.ch2.timespace;
public class UnsignedByte {
public short getValue(byte i) {
short li = (short) (i & 0xff);
return li;
}
public byte toUnsignedByte(short i) {
return (byte) (i & 0xff);
}
public static void main(String args[]) {
UnsignedByte ins = new UnsignedByte();
short[] shorts=new short[256];
for(int i=0;i<shorts.length;i++)
shorts[i]=(short)i;
byte[] bytes=new byte[256];
for(int i=0;i<bytes.length;i++)
bytes[i]=ins.toUnsignedByte(shorts[i]);
for(int i=0;i<bytes.length;i++)
System.out.print(ins.getValue(bytes[i])+" ");
}
}
java不支持无符号整数的替代示例方案
猜你喜欢
转载自blog.csdn.net/qq_37769323/article/details/104189350
今日推荐
周排行