How do you convert a character type into a string type??

Recommended Answers

All 3 Replies

char c = 'a';
String s = new String("" + c);

char c = 'a';
String s = new String("" + c);

It is easier to do this: String s = c + ""; But this is better: String s = String.valueOf(c); I have checked and the latter is faster

Thank you!!!!!!!!! (^-^)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.