Scala Char toString() method with example
The toString() method is utilized to convert a stated character into String.
Method Definition: def toString: String
Return Type: It returns the String representation of the stated character.
Example: 1#
// Scala program of toString() // method // Creating object object GfG { // Main method def main(args : Array[String]) { // Applying toString method val result = 'B' .toString // Displays output println(result) } } |
Output:
B
Example: 2#
// Scala program of toString() // method // Creating object object GfG { // Main method def main(args : Array[String]) { // Applying toString method val result = 'b' .toString // Displays output println(result) } } |
Output:
b
Please Login to comment...