提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
将字符串转换为字节
/** 时 代 J a v a 提供 **/ public class Main { public static void main(String[] args) { //1. Construct Byte using constructor. Byte bObj1 = new Byte("100"); System.out.println(bObj1); //2. Use valueOf method of Byte class. This method is static. String str = "100"; Byte bObj2 = Byte.valueOf(str); System.out.println(bObj2); } }