Java中如何将String转Byte呢?
下文笔者讲述java代码如何将String转Byte数据类型的方法分享,如下所示
String转byte的实现思路
方式1: 使用Byte.decode()方法直接转换 方式2: String转int int转byte例
//使用Byte.decode() String str = "8"; Byte decode = Byte.decode(str); System.out.println(decode); //String转为int //int转化内byte //byte转为Byte String str = "8"; int i = Integer.parseInt(str); Byte aByte = (Byte)(byte)i; System.out.println(aByte);
版权声明
本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。