HOW TO CONVERT A CHAR TO A STRING IN JAVA?

Jayne Spooner

Total Post:21

Points:147
Posted by  Jayne Spooner
Java  String 
 723  View(s)
Ratings:
Rate this:
I have a char and I need a String. How do I convert from one to the other?
  1. Mayank Tripathi

    Post:397

    Points:3117
    Re: How to convert a char to a string in Java?

    Here are various ways to convert char into String:


    String stringValueOf = String.valueOf('c');

    String characterToString = Character.toString('c');

    String characterObjectToString = new Character('c').toString();

    .String concatBlankString = 'c' + "";

    String fromCharArray = new String(new char[]{x});

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!