Scala String startsWith(String prefix) method with example Last Updated : 29 Oct, 2019 Comments Improve Suggest changes Like Article Like Report 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# Scala // Scala program of startsWith() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Applying startsWith method val result = "GeeksforGeeks".startsWith("Geeks") // 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("geeks") // Displays output println(result) } } Output: false Comment More infoAdvertise with us Next Article Scala String startsWith(String prefix) method with example N nidhi1352singh Follow Improve Article Tags : Scala Scala Scala-Method Scala-Strings Similar Reads Scala String startsWith(String prefix, int toffset) method with example 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 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 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 Scala String substring() method with example The substring() method is utilized to find the sub-string from the stated String which starts from the index specified. Method Definition: String substring(int beginIndex) Return Type: It returns the content from the given String Which starts from the index we specify. Example: 1# Scala // Scala pro 1 min read Like