Scala String intern() method with example
The intern() method is utilized to check the canonical presentation of the string object.
Method Definition: String intern()
Return Type: It returns the canonical presentation of the string object.
Example: 1#
// Scala program of int intern()// method // Creating objectobject GfG{ // Main method def main(args:Array[String]) { // Applying intern method val result = "GeeksforGeeks, \n\tA CS portal.".intern() // Displays output println(result) }} |
Output:
GeeksforGeeks, A CS portal.
Example: 2#
// Scala program of int intern()// method // Creating objectobject GfG{ // Main method def main(args:Array[String]) { // Applying intern method val result = "My name is Nidhi, \ni am an author.".intern() // Displays output println(result) }} |
Output:
My name is Nidhi, i am an author.


