Java.lang.Byte.toString() 方法
描述
java.lang.Byte.toString(byte b) 返回一个表示指定字节的新 String 对象。 基数假定为 10。
声明
以下是 java.lang.Byte.toString() 方法的声明。
public static String toString(byte b)
参数
b − 要转换的字节
返回值
该方法返回指定字节的字符串表示形式。
异常
NA
示例
下面的例子展示了 lang.Byte.toString() 方法的使用。
package com.tutorialspoint;
import java.lang.*;
public class ByteDemo {
public static void main(String[] args) {
// create a byte primitive bt and asign value
byte bt = 20;
// create a String s
String s;
/**
* static method is called using class name. Assign
* string representation of bt to s
*/
s = Byte.toString(bt);
String str = "String representation of byte primitive " +bt+ " is " +s;
// print s value
System.out.println( str );
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
String representation of byte primitive 20 is 20

