Scala String intern() method with example
Last Updated :
03 Oct, 2019
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#
object GfG
{
def main(args : Array[String])
{
val result = "GeeksforGeeks, \n\tA CS portal." .intern()
println(result)
}
}
|
Output:
GeeksforGeeks,
A CS portal.
Example: 2#
object GfG
{
def main(args : Array[String])
{
val result = "My name is Nidhi, \ni am an author." .intern()
println(result)
}
}
|
Output:
My name is Nidhi,
i am an author.
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...