Java Program to convert Char array to String

Java 8Object Oriented ProgrammingProgramming

To convert Char array to String in Java, use the valueOf() method.

Here is our character array.

char[] arr = {'p','q'};

Converting it to string.

String.valueOf(arr)

The following is the final example.

Example

 Live Demo

public class Demo {
   public static void main(String[] args) {
      char[] arr = {'p','q'};
      // converting
      System.out.println(String.valueOf(arr));
   }
}

Output

pq
raja
Updated on 26-Jun-2020 16:57:09

Advertisements