将字节转换为Java中的数字原始数据类型
要将Byte转换为数字原始数据类型,请使用以下方法-
byteValue() shortValue() intValue() longValue() floatValue()
首先,让我们声明一个字节。
Byte字节Val = new字节("35");现在,让我们来看一个简单的示例,如何将其转换为long类型。
long longVal =字节Val.longValue(); System.out.println(longVal);
以相同的方式,您可以将其转换为其他原始数据类型,如下面完整的示例所示-
示例
public class Demo {
public static void main(String args[]) {
//字节
字节字节Val = new字节("35");
字节 b =字节Val.byteValue();
System.out.println(b);
short shortVal =字节Val.shortValue();
System.out.println(shortVal);
int intVal =字节Val.intValue();
System.out.println(intVal);
long longVal =字节Val.longValue();
System.out.println(longVal);
float floatVal =字节Val.floatValue();
System.out.println(floatVal);
double doubleVal =字节Val.doubleValue();
System.out.println(doubleVal);
}
}输出结果
35 35 35 35 35.0 35.0
热门推荐
10 工人生日祝福语简短
11 恋爱祝福语大全简短搞笑
12 送给姐姐简短的祝福语
13 祝福语简短唯美10字
14 生日祝福语简短明了 同事
15 收到公公生日祝福语简短
16 老婆生日祝福语短句简短
17 讲课祝福语简短10字
18 阳历新年祝福语大全 简短