Java.lang Package Classes

Java - String valueOf() Method



The Java string valueOf() method returns the string representation of the character array argument.

Syntax

public static String valueOf(char[] data)

Parameters

data specify a character array.

Return Value

Returns a string that contains the characters of the character array.

Exception

NA.

Example:

In the example below, valueOf() method returns the string representation of the character array argument.

import java.lang.*;

public class MyClass {
  public static void main(String[] args) {
    char[] x1 = {'H', 'e', 'l', 'l', 'o'};
    System.out.println(String.valueOf(x1)); 
  }
}

The output of the above code will be:

Hello

❮ Java.lang - String