static String toString(byte b)
描述 (Description)
java.lang.Byte.toString(byte b)返回一个表示指定字节的新String对象。 假设基数为10。
声明 (Declaration)
以下是java.lang.Byte.toString()方法的声明
public static String toString(byte b)
参数 (Parameters)
b - 要转换的字节
返回值 (Return Value)
此方法返回指定字节的字符串表示形式。
异常 (Exception)
NA
例子 (Example)
以下示例显示了lang.Byte.toString()方法的用法。
package com.iowiki;
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