Two methods we can use to convert a byte value to a string value. First method is the toString method from Byte class
Return | Method | Summary |
---|---|---|
String | toString() | Returns a String object representing this Byte's value. |
public class Main {
public static void main(String[] args) {
Byte byteObject = new Byte("10");
String str = byteObject.toString();
System.out.println("str:"+str);
}
}
The outputs:
str:10
Another way is to use the static method toString(byte b).
Return | Method | Summary |
---|---|---|
static String | toString(byte b) | Returns a new String object representing the specified byte. |
public class Main {
public static void main(String[] args) {
byte b = 10;
System.out.println("str:"+Byte.toString(b));
}
}
The output:
str:10
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |