In this example, We will discuss about toString() method of character class.
Example For toString() method of character class
In this example, We will discuss about toString() method of character class. This method returns a string object that represents the specified character. As a result we get a string of single character. The character is passed as a parameter to the method.
Example: CharacterToString.java
package com.devmanuals; public class CharacterToString { public static void main(String[] args) { System.out.print("The one character string is= "); System.out.println(Character.toString('R')); System.out.print("The one character string is= "); System.out.println(Character.toString('K')); System.out.print("The one character string is= "); System.out.println(Character.toString('m')); } }
Output:
The one character string is= R
The one character string is= Khe one chracter string is= m |
[ 0 ] Comments