FIND YOUR ANSWER

Friday, 12 December 2014

How to convert a char to a string in Java?

I have a char and I need a String. How do I convert from one to the other?

 

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});

 

Posted by Sunil Sahu at 08:43 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Newer Posts Home
Subscribe to: Comments (Atom)

About Me

My photo
Sunil Sahu
View my complete profile

Blog Archive

  • ▼  2014 (8)
    • ▼  December (8)
      • JDBC-ODBC Conncection in java with MyEclipse
      • Three letter pattern A string str has been provide...
      • ChangeStringCase Problem Statement Given a string...
      • Given three strings s1, s2 and s3 as input, return...
      • Given a string as input, return the following outp...
      • Given a string as Input check the maximum number o...
      • Given a string as input, return a string containin...
      • How to convert a char to a string in Java?
Simple theme. Powered by Blogger.