Share on Google+Share on Google+

Convert Character into a String

In this section, you will learn how to convert a char into a string type data.

Convert Character into a String


In this section, you will learn how to convert a char into a string type data. The java.lang package provides the functionality to convert a character into a string. 

Code Description:

This program takes a character at the console and converts it into a string format using by the toString() method. This method converts the character into an integer type data. The character class wraps a value of the primitive type char in an object. The toString method returns a string object representing this character's values.

Here is the code of this program:

import java.lang.*;

public class CharToString{
  public static void main(String args[])throws IOException{
  BufferedReader read = 
new BufferedReader(new InputStreamReader(;
  System.out.println("Enter a Character:");
  String s = read.readLine();
  char c = s.charAt(0);
  System.out.println("Character value is " + c);
  String s1 = Character.toString(c);
  System.out.println("String value is " + s1);

Download of this program:

Output of this program.

C:\corejava>java CharToString
Enter a Character:
Character value is R
String value is R


Posted on: June 15, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Discuss: Convert Character into a String   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
April 14, 2011

thanks it's really helpful. :D
June 8, 2011
not wkg

st="india is my country" i hav to store each word in a sep array mean newSt=newSt+st.charAt(i) is not making a word... i m unable to form a word
August 23, 2011

how to convert string to character in java?
November 29, 2011
array of char

ok, but if I want to convert an array of char to string ?
April 2, 2012

You never handled a char. You just took Strings T_T
Aldo Joaquin Cortés García
April 15, 2013

Thank you, i was looking for this,it really helped me. Good Work