Char to string in java

Java convert char to string using Character.toString() method

package com.w3schools;

public class CharToString {
  public static void main(String args[]){
      char ch = 'a';
      //Convert char to string
      String str = Character.toString(ch);
      System.out.println("String is: "+str);
  }
}

Output:

String is: a

Download this example.

Java convert char to string using String.valueOf() method

package com.w3schools;

public class CharToString {
  public static void main(String args[]){
      char ch = 'a';
      //Convert char to string
      String str = String.valueOf(ch);
      System.out.println("String is: "+str);
  }
}

Output:

String is: a

Download this example.