多语言展示
当前在线:709今日阅读:99今日分享:20

java基础8.3.2 包装类之Byte2

继续来讲Byte的一些方法。
工具/原料
1

电脑

2

java

方法/步骤
1

int i = aByte.intValue();将一个Byte类型返回为int类型

2

byte b = Byte.parseByte('3');Byte的静态方法,将字符串数字转化为byte

3

String s = aByte.toString();将Byte转化为string类型的数

5

Byte也提供了几个常量:byte maxValue = Byte.MAX_VALUE;//byte可取的最大值byte minValue = Byte.MIN_VALUE;//byte可取的最小值Class type = Byte.TYPE;  //byte的Class类型int size = Byte.SIZE;          //byte以二进制补码的位数

注意事项

String转化为byte是必须是纯数字,否则会报错异常

推荐信息