Scala String endsWith() method with example Improve Improve Like Article Like Save Share Report 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: // Scala program of endsWith() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a String val m1= "Nidhi" // Applying endsWith() method val result = m1.endsWith("i") // Displays output println(result) } } Output: true Example #2: // Scala program of endsWith() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a String val m1= "Nidhi" // Applying endsWith() method val result = m1.endsWith("y") // Displays output println(result) } } Output: false Last Updated : 03 Oct, 2019 Like Article Save Article Previous Scala String replaceAll() method with example Next Scala String equalsIgnoreCase() method with example Share your thoughts in the comments Add Your Comment Please Login to comment...