Programming
Java
Data conversion
String
Char

How to convert a char to a String?

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

In Java, converting a char to a String is simple, but some approaches are clearer than others. The most idiomatic options are String.valueOf(ch) and Character.toString(ch), while concatenation with an empty string works but is usually less explicit.

The Cleanest Option: String.valueOf

For most Java code, String.valueOf is the most straightforward answer.

java
1public class Main {
2    public static void main(String[] args) {
3        char ch = 'A';
4        String text = String.valueOf(ch);
5
6        System.out.println(text);
7    }
8}

This is clear, standard, and easy for other Java developers to recognize immediately.

It also scales well because the same method works for many different value types, not just char.

Another Good Option: Character.toString

Java also offers Character.toString.

java
1public class Main {
2    public static void main(String[] args) {
3        char ch = 'B';
4        String text = Character.toString(ch);
5
6        System.out.println(text);
7    }
8}

This is equally valid. Some developers like it because it makes the type relationship more explicit: a Character utility converts the char into text.

In day-to-day code, String.valueOf and Character.toString are both good choices. The difference is mostly style.

Concatenation Also Works

You will often see this:

java
1public class Main {
2    public static void main(String[] args) {
3        char ch = 'C';
4        String text = ch + "";
5
6        System.out.println(text);
7    }
8}

This works because Java turns the expression into string concatenation. But it is less explicit about intent, and many teams prefer the conversion methods above because they read more clearly.

So while concatenation is valid, it is usually not the cleanest first choice.

Converting Multiple Characters

If you are converting more than one char, do not convert them one at a time unnecessarily. Build a string from the character array instead.

java
1public class Main {
2    public static void main(String[] args) {
3        char[] chars = {'J', 'a', 'v', 'a'};
4        String text = new String(chars);
5
6        System.out.println(text);
7    }
8}

That is a different case from single-character conversion, but it matters because beginners sometimes overuse individual conversions when they already have an array or sequence.

Why This Comes Up in Real Code

Single-character to string conversion appears in many small tasks:

  • building parser tokens
  • appending characters to output
  • working with StringBuilder
  • converting user input from char-based APIs
  • formatting messages

For example, if a parser reads one char and needs a String key:

java
1public class Main {
2    public static void main(String[] args) {
3        char token = ':';
4        String key = String.valueOf(token);
5
6        System.out.println("Token is " + key);
7    }
8}

The conversion itself is simple, but choosing the readable form helps once the code is embedded in a larger method.

char Is Not the Same as String

It is worth remembering that Java treats char and String very differently:

  • 'char is a primitive representing one UTF-16 code unit'
  • 'String is an object representing a sequence of characters'

That is why the conversion is explicit. A character literal such as 'A' is not a string literal such as "A".

This also explains why APIs sometimes require a String even when you only have one visible character. The types are intentionally different.

Watch Out for Unicode Assumptions

For ordinary Latin letters, a char often feels like “one character.” But in Java, some Unicode characters require more than one UTF-16 code unit. That means not every user-visible symbol can be represented as a single char.

So this article’s question is specifically about converting one Java char into a String, not about converting any possible Unicode symbol into a one-character string safely. That difference matters when you work with emoji or characters outside the Basic Multilingual Plane.

For a plain char, though, the conversion methods shown above are correct.

Common Pitfalls

The most common pitfall is overusing concatenation with "" everywhere instead of using String.valueOf or Character.toString, which make the intent clearer.

Another mistake is confusing 'A' and "A". One is a char, the other is a String.

A third issue is assuming every visible symbol fits in one Java char. That is not true for all Unicode text.

Finally, some developers convert characters one by one when they already have a char[]. In that case, build the string from the array directly.

Summary

  • In Java, the cleanest ways to convert a char to String are String.valueOf(ch) and Character.toString(ch).
  • Concatenation with "" also works but is usually less explicit.
  • Use new String(charArray) when converting multiple characters together.
  • Remember that char and String are different Java types.
  • Be careful not to generalize one-char logic to all Unicode text without thinking about surrogate pairs.

Related reading
Course
Intermediate
27 lessons
14 hours
OOD Fundamentals

Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.