Scala String substring(int beginIndex, int endIndex) method with example Last Updated : 29 Oct, 2019 Comments Improve Suggest changes Like Article Like Report The substring(int beginIndex, int endIndex) method is utilized to find the sub-string from the stated String which starts and ends with the index specified. Method Definition: String substring(int beginIndex, int endIndex) Return Type: It returns string which is the part of the stated String. Note: It is same as sub-sequence method but the only difference between the two is that sub-sequence returns CharSequence but the above method returns string. Example: 1# Scala // Scala program of substring() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Applying substring method val result = "GeeksforGeeks".substring(4, 8) // Displays output println(result) } } Output: sfor Example: 2# Scala // Scala program of substring() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Applying substring method val result = "GeeksforGeeks".substring(0, 4) // Displays output println(result) } } Output: Geek Comment More infoAdvertise with us Next Article Scala String substring(int beginIndex, int endIndex) method with example N nidhi1352singh Follow Improve Article Tags : Scala Scala Scala-Method Scala-Strings Similar Reads 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 Scala String indexOf(String str, int fromIndex) method with example The indexOf(String str, int fromIndex) method is utilized to return the index of the sub-string which occurs first from the index we specify in the string stated. Method Definition: int indexOf(String str, int fromIndex) Return Type: It returns the index of the sub-string from the index specified in 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 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 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 Like