Scala String equals() method with example
Last Updated :
03 Oct, 2019
The equals() method is utilized to check if the stated string and object are equal.
Method Definition: Boolean equals(Object anObject)
Return Type: It returns true if the string is same as the object stated else it returns false.
Example #1:
object GfG
{
def main(args : Array[String])
{
val m 1 = Array( 'N' , 'i' , 'd' , 'h' , 'i' )
val result = "Nidhi" .equals( "Nidhi" )
println(result)
}
}
|
Example #2:
object GfG
{
def main(args : Array[String])
{
val m 1 = Array( 'N' , 'i' , 'd' , 'h' , 'i' )
val result = "Nidhi" .equals( "Nidh" )
println(result)
}
}
|
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...