java:Byte类

Instructions

  • byte class

  • byte (class octet)

  • Value (value)

  • It can be a byte value returned by Byte object method byteValue

  • Problems encountered
    1. The object is named b_0, if it is 0_b be wrong
    2.Byte value can not be 36 764. Because Byte class int maximum desirable class 127, more than this number of compiler error. Preferably the minimum -128,
    -128 will compile error.

  • Byte class also provides four constants:
    MIN_MALUE: class byte desirable minimum
    MAX_MALUE: byte maximum desirable class
    SIZE: byte values used to represent the binary digit complement form
    TYPE: byte indicates the type of the basic Class Examples

Source

class Demo{
	public static void main(String[] args){
		int	max_int_0=Byte.MAX_VALUE;								//获取Byte类对int类可取最大值
			System.out.println("Byte类对int类可取最大值:"+max_int_0);
		int	min_int_0=Byte.MIN_VALUE;								//获取Byte类对int类可取最小值
			System.out.println("Byte类对int类可取最小值:"+min_int_0);
		int size_int_0=Byte.SIZE;									//二进制补码形式表示byte值位数
			System.out.println("Byte类二进制补码形式表示byte值的位数:"+size_int_0+"\n");

		byte byte_0=36;												//初始化byte类byte_0为764
		Byte b_0=new Byte(byte_0);									//声明Byte对象b_0,且b_0内容为byte_0
			System.out.println("Byte对象的值为:"+b_0.byteValue());	//输出Byte对象b_0的值,用Value的方法
	}
}

operation result

Here Insert Picture Description

Published 66 original articles · won praise 11 · views 1639

Guess you like

Origin blog.csdn.net/qq_44925904/article/details/104115082