In this tutorial, I will show you all how to convert char to String in Java. Let consider the following example:
|
|
package com.huongdanjava.javaexample; public class Example { public static void main(String[] args) { char c = 'K'; } } |
To convert this character “K” to String, we will use the Character object with method toString() as below:
|
|
package com.huongdanjava.javaexample; public class Example { public static void main(String[] args) { char c = 'K'; String s = Character.toString(c); System.out.println(s); } } |
Result: