Java String(byte[] bytes) Constructor

Syntax

String(byte[] bytes) constructor from String has the following syntax.

public String(byte[] bytes)

Example

In the following code shows how to use String.String(byte[] bytes) constructor.


public class Main {
  public static void main(String args[]) {
    byte ascii[] = { 65, 66, 67, 68, 69, 70 };
/*from  w ww.j  ava2  s .c  o  m*/
    String s1 = new String(ascii);
    System.out.println(s1);

  }
}

The output:





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable