Java Byte toString()方法及示例
Byte类的 toString() 方法是Java中的一个内置方法,用于返回一个字符串值。
public String toString()
语法。
ByteObject.toString()
返回值: 它返回一个字符串对象,它的值等于ByteObject的值。
下面是toString()方法的实现。
// Java code to implement// toString() method of Byte class class GFG { public static void main(String[] args) { // byte value byte value = 19; // creating a byte Object Byte b = new Byte(value); // toString() method in Byte class String output = b.toString(); // printing the output System.out.println(output); }}
输出:
19
public static String toString()
语法
Byte.toString(byte b)
参数: 它接收一个字节值b作为参数,该字节值将被转换为字符串。
返回类型: 它返回一个字符串对象,该对象的值等于字节’b’的值。
下面是toString()方法的实现。
// Java code to implement// toString() method of Byte class class GFG { public static void main(String[] args) { // byte value byte value = 19; // toString() method og Byte class String output = Byte.toString(value); // printing the output System.out.println(output); }}
输出:
19
