The Parameters
Substring to search for, coerced to a string. If the method is called with no arguments, position OptionalThe method returns the index of the last occurrence of the specified substring at a position less than or equal to
Return valueThe index of the last occurrence of DescriptionStrings are zero-indexed: The index of a string's first character is
Case-sensitivity The
ExamplesUsing indexOf() and lastIndexOf() The following example uses
Specifications
Browser compatibilityBCD tables only load in the browser See alsoWhich of the following method call gives the position of the first occurrence of x in the string 51?The charAt() method returns the character at the specified index in a string. The index of the first character is 0, the second character is 1, and so on.
What is use of charAt () method Mcq?Explanation: charAt() return one character only not array of character.
How do you find the first index of a substring in a given string?The indexOf() method returns the position of the first occurrence of specified character(s) in a string. Tip: Use the lastIndexOf method to return the position of the last occurrence of specified character(s) in a string.
Which of the following methods will create string in Java Mcq?The intern() and toString() methods are of String class. Hence, the correct answer is option (c).
|