Scala String indexOf(String str, int fromIndex) method with example
Last Updated :
03 Oct, 2019
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:
object GfG
{
def main(args : Array[String])
{
val result = "Nidhisinghis" .indexOf( "his" , 4 )
println(result)
}
}
|
Example #2:
object GfG
{
def main(args : Array[String])
{
val result = "Nidhisinghis" .indexOf( "is" , 5 )
println(result)
}
}
|
Share your thoughts in the comments
Please Login to comment...