How to convert char to String in Java

Here’s a Java program to show you how to convert Char to String or vise verse.

package com.mkyong;
public class ConvertCharToString {
	public static void main(String[] args) {
		String website = "";
		//convert a String into char
		char charData = website.charAt(11);
		//convert char back to String
		String temp = Character.toString(charData);
		if ("m".equals(temp)) {


Tags :

About the Author

Founder of and, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider make a donation to these charities.


  • Diva

    you can find some more details in the below link,””

  • Kevin

    You sir, are God sent. The small amount of code you have shown here has been more enlightening than the majority of forums I have searched.

    I am now able to figure out how to get the basic concept for ‘reversing text in a file’.

    This is what I have so far, it is definitely not complete and does not reverse all the text in a file. However, with the basic concept you have displayed using the toString() method in the Character class, I have the following code in my test driver:

    public class ReverseText
    public static void main(String[] args) throws FileNotFoundException
    File inputFile = new File(“Solar_System_Info.txt”);

    Scanner in = new Scanner(inputFile);

    String info = in.nextLine();

    char processInfo = info.charAt(info.length()-1);

    String reverse = Character.toString(processInfo);

    char processInfo2 = info.charAt(info.length()-2);

    reverse = reverse + Character.toString(processInfo2);



  • Max Dalton

    Thanks for this, very nice explanation.

  • Jamie

    this example seems more to be for converting strings to char and why are throwing in the if statment? just confuses the issue

    • mkyong

      “website.charAt(11)” will return a char and later use “Character.toString()” to convert char to String.

      The if statement is used to show that the char is converted into string and can be used for string compare.