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
Published on 13-Dec-2018 10:10:34
Advertisements