java byte转无符号int

java byte转无符号int
import java.io.ByteArrayInputStream;

public class Test{

    public static void main(String[] args) {

        byte[] bytes =  new byte[]{(byte)-42};
        
        ByteArrayInputStream in = new ByteArrayInputStream(bytes);
        
        int result = in.read();
        System.out.println("无符号数: \t"+result);
        System.out.println("2进制bit位: \t"+Integer.toBinaryString(result));
    }
}
java byte转无符号int

 

java byte转无符号int,布布扣,bubuko.com

java byte转无符号int

上一篇:java如何获取IP地址


下一篇:C++经典面试题