Java: Converting a char to a string

Abs :

I have just done this in eclipse:

String firstInput = removeSpaces(myIn.readLine());
String first = new String(firstInput.charAt(0));

However, eclipse complains that:

The constructor String(char) is undefined

How do I convert a char to a string then??

Thanks

EDIT

I tried the substring method but it didn't work for some reason but gandalf's way works for me just fine! Very straightforward!

Gandalf :

Easiest way?

String x = 'c'+"";

or of course

String.valueOf('c');

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related