Scala String endsWith() method with example
Last Updated :
03 Oct, 2019
The endsWith() method is utilized to check if the stated string ends with the suffix stated in the argument.
Method Definition: Boolean endsWith(String suffix)
Return Type: It returns true if the string ends with the suffix stated else it returns false.
Example #1:
object GfG
{
def main(args : Array[String])
{
val m 1 = "Nidhi"
val result = m 1 .endsWith( "i" )
println(result)
}
}
|
Example #2:
object GfG
{
def main(args : Array[String])
{
val m 1 = "Nidhi"
val result = m 1 .endsWith( "y" )
println(result)
}
}
|
Share your thoughts in the comments
Please Login to comment...