Tutorialspoint

1 Answer
karthikeya Boyini
, 0 Views

The valueOf() method is used in Java to convert char array to string.

Here is our char array.

// char array
char[] c = {'p','q','r','s','t','u','v'};

To convert it to string, use the valueOf() method.

String str = String.valueOf(c);

Example

Live Demo

public class Demo {
   public static void main(String[] args)  {
      // char array
      char[] c = {'p','q','r','s','t','u','v'};
      // converting to string
      String str = String.valueOf(c);
      System.out.println("String: "+str);
   }
}

Output

String: pqrstuv

Advertisements