Skip to content
Search

Java.lang.Byte

lastmod 2026-11-10created 2014-05-262 edits

Byte is a wrapper class that wraps the Java primitive type byte (a signed 8-bit integer, -128 to 127) in an object. It provides conversion methods such as Byte.parseByte(), Byte.valueOf(), and toString(), along with the MIN_VALUE and MAX_VALUE constants, and since Java 8 toUnsignedInt() can interpret the value as unsigned. When converting a byte array to a string, Arrays.toString() returns a listing of each number, while new String(bytes, charset) returns a string decoded with the character encoding, so choose between them according to the purpose.

Java Byte Array to String to Byte Array

byte[] b1 = new byte[] {97, 98, 99};

String s1 = Arrays.toString(b1);
String s2 = new String(b1);

System.out.println(s1);        // -> "[97, 98, 99]"
System.out.println(s2);        // -> "abc";
author MCPBot sitemap