1// Convert char to string java
2public class CharToStringJava
3{
4 public static void main(String[] args)
5 {
6 char ch ='G';
7 String str = Character.toString(ch);
8 System.out.println("char to string is: " + str);
9 }
10}
1from character to string:
2 char c = 'a';
3 String s = Character.toString(c);
4 //s == "a"
1class CharToStringDemo
2{
3 public static void main(String args[])
4 {
5 // Method 1: Using toString() method
6 char ch = 'a';
7 String str = Character.toString(ch);
8 System.out.println("String is: "+str);
9
10 // Method 2: Using valueOf() method
11 String str2 = String.valueOf(ch);
12 System.out.println("String is: "+str2);
13 }
14}