12.How to convert char to String
💡Code:
public class CharToStringConversion7078 {
public static void main(String[] args) {
// Example char
char character = 'A';
// Convert char to String using Character.toString()
String str1 = Character.toString(character);
// Convert char to String by concatenating with an empty String
String str2 = "" + character;
// Print the converted Strings
System.out.println("Converted String 1: " + str1);
System.out.println("Converted String 2: " + str2);
}
}
📸Output :