- Purpose of IndexOf (): For finding strings of substrings
- IndexOf () Usage: Returns the first occurrence of a string string in a character indexOf (string) in the parent string, starting at 0 and not returning-1.
-
syntax
stringobject.indexof (searchvalue,fromindex)
parameter description
searchvalue required. Specifies the string value that needs to be retrieved.
fromindex Optional integer parameter. Specifies where to start retrieving in the string. Its legal value is 0 to-1. If this argument is omitted, it is retrieved from the first character of the string.
description
Span style= "font-family: Song body; Font-size:18px "> This method will retrieve the string stringobject from beginning to end to see if it contains substring searchvalue. The location at which to begin retrieving is at the fromindex of the string or at the beginning of the string (when no fromindex is specified). If a searchvalue is found, the position of the first occurrence of the Searchvalue is returned. The character position in Stringobject is starting at 0.
4 different methods
The IndexOf () method of the string class of Java strings