Scala String indexOf(String str, int fromIndex) method with example Last Updated : 03 Oct, 2019 Comments Improve Suggest changes Like Article Like Report 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 the argument. Example #1: Scala // Scala program of int indexOf() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Applying indexOf method val result = "Nidhisinghis".indexOf("his", 4) // Displays output println(result) } } Output: 9 Example #2: Scala // Scala program of int indexOf() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Applying indexOf method val result = "Nidhisinghis".indexOf("is", 5) // Displays output println(result) } } Output: 10 Comment More infoAdvertise with us Next Article Scala String indexOf(String str, int fromIndex) method with example nidhi1352singh Follow Improve Article Tags : Scala Scala Scala-Method Scala-Strings Similar Reads Scala String lastIndexOf(String str, int fromIndex) method with example The lastIndexOf(String str, int fromIndex) method is utilized to return the index of the last appearance of the sub-string we specify in the argument from the index specified from right to left from the stated string. Method Definition: int lastIndexOf(String str, int fromIndex) Return Type: It retu 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 indexOf(int ch, int fromIndex) method with example The indexOf(int ch, int fromIndex) method is same as indexOf() method but here this method starts finding the character from the index we specify. Method Definition: int indexOf(int ch, int fromIndex) Return Type: It returns the index of the character specified in the argument. Example #1: Scala // 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 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(int ch, int fromIndex)() method with example The lastIndexOf() method is utilized to return the index of the last appearance of the character we specify in the argument from the index we specify for the stated string. Method Definition: int lastIndexOf(int ch, int fromIndex) Return Type: It returns the index of the last appearance of the chara 1 min read Scala String indexOf() method with example The indexOf() method is utilized to find the index of the first appearance of the character in the string and the character is present in the method as argument. Method Definition: int indexOf(int ch) Return Type: It returns the index of the character stated in the argument. Example #1: Scala // Sca 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 Scala String lastIndexOf() method with example The lastIndexOf() method is utilized to return the index of the last appearance of the character we specify in the argument from the stated string. Method Definition: int lastIndexOf(int ch) Return Type: It returns the index of the last appearance of the character in the argument. Example #1: Scala 1 min read Scala String substring(int beginIndex, int endIndex) method with example 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: 1 min read Like