Scala String startsWith(String prefix, int toffset) method with example Last Updated : 29 Oct, 2019 Comments Improve Suggest changes Like Article Like Report The startsWith(String prefix, int toffset) method is utilized to check if the stated string starts with the prefix or not that is being specified by us at the specified index. Method Definition: Boolean startsWith(String prefix, int toffset) Return Type: It returns true if the string starts with the specified prefix at the specified index else it returns false. Example: 1# Scala // Scala program of startsWith() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Applying startsWith method val result = "GeeksforGeeks".startsWith("eks", 2) // Displays output println(result) } } Output: true Example: 2# Scala // Scala program of startsWith() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Applying startsWith method val result = "GeeksforGeeks".startsWith("Eks", 2) // Displays output println(result) } } Output: false Comment More infoAdvertise with us Next Article Scala String startsWith(String prefix, int toffset) method with example N nidhi1352singh Follow Improve Article Tags : Scala Scala Scala-Method Scala-Strings Similar Reads Scala String startsWith(String prefix) method with example The startsWith(String prefix) method is utilized to check if the stated string starts with the prefix or not that is being specified by us. Method Definition: Boolean startsWith(String prefix) Return Type: It returns true if the string starts with the specified prefix else it returns false. Example: 1 min read Scala String split(String regex, int limit) method with example The split(String regex, int limit) method is same as split(String, regex) method but the only difference here is that you can limit the number of elements in the resultant Array. Method Definition: String[] split(String regex, int limit) Return Type: It returns a String array where, the number of el 1 min read Scala String indexOf(String str) method with example The indexOf(String str) method is utilized to return the index of the sub-string which occurs first in the string stated. Method Definition: indexOf(String str) Return Type: It returns the index of the sub-string which is specified in the argument of the method. Example #1: Scala // Scala program of 1 min read Scala String lastIndexOf(String str) method with example The lastIndexOf(String str) method is utilized to return the index of the last appearance of the sub-string we specify in the argument from the stated string. Method Definition: int lastIndexOf(String str) Return Type: It returns the index of the last appearance of the sub-string specified in the ar 1 min read Scala String toString() method with example The toString() method is utilized to return a string object itself. Method Definition: String toString() Return Type: It returns the string object. Example: 1# Scala // Scala program of toString() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Applying toS 1 min read Like