java.lang.Byte.toString(byte b)%uA0返回表示指定的字节一个新的String对象。基数被假定为10。
声明
以下是java.lang.Byte.toString()方法的声明
public static String toString(byte b)
参数
-
b%uA0- 该字节被转换
返回值
此方法将返回指定字节的字符串表示形式。
异常
-
NA
例子
下面的例子显示了lang.Byte.toString()方法的使用。
package com.yiibai 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