Java Character toString() Method
Example
Convert a character to a string, and print the length of the string:
public class Main {
public static void main(String[] args) {
String myString = Character.toString('A');
System.out.println(myString);
System.out.println(myString.length());
}
}
Definition and Usage
The toString() method converts a char to a String that has only that one character.
Use it when you need a string, for example to call String methods like length().
Syntax
public static String toString(char c)
Parameter Values
| Parameter | Description |
|---|---|
| c | Required. The character to convert. |
Technical Details
| Returns: | A String with the character. |
|---|
Related Pages
❮ Character Methods