Java Program to Convert Character to String


The toString() method of the Character class converts the character to string. You can use this method to convert the given character to String.

Example

import java.util.Scanner;
public class CharToString {
   public static void main(String args[]){
      System.out.println("Enter a character ::");
      Scanner sc = new Scanner(System.in);
      char ch = sc.next().charAt(0);
      String str = Character.toString(ch);
      System.out.println(str);
   }
}

Output

Enter a character ::
h
h

Updated on: 13-Mar-2020

521 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements