Write a java program to convert char to String by using toString() method.
时间: 2024-05-05 15:18:37 浏览: 97
Sure! Here's a sample Java program to convert a char to a String using the toString() method:
```
public class CharToStringExample {
public static void main(String[] args) {
char c = 'a'; // char to convert
String str = Character.toString(c); // convert char to String using toString() method
System.out.println("Converted string: " + str);
}
}
```
Running this program will output the following:
```
Converted string: a
```
Let me know if you have any other questions!
阅读全文