indexOf( ) method in string | java | ICSE X | class 10 | Semester 2 | computer applications

preview_player
Показать описание
The indexOf() method returns the position of the first occurrence of specified character(s) in a string.
Syntax:
There are 4 indexOf( ) methods :
public int indexOf(String str)
public int indexOf(String str, int fromIndex)
public int indexOf(int char)
public int indexOf(int char, int fromIndex)

PARAMETERS USE:
str - A String value, representing the string to search for.
fromIndex - An int value, representing the index position to start the search from.
char - An int value, representing a single character, e.g 'A', or a Unicode value.

Returns: An int value, representing the index of the first occurrence of the character in the string, or -1 if it never occurs.

CODE:
class indexOf
{
static void main()
{
}
}

OUTPUT:
3
10
0
1
5

Click on this google drive link to get the code of the program :

#ICSE
#icse
#boards
#class 10
# semester 2
#computer applications
#java
#string
#java
#string handling
#2022
Рекомендации по теме
Комментарии
Автор

Thanks sir very helpful. I am a student of ICSE board and this video helped a lot. I understood all other string functions but this index was a problem and hopefully I got such a nice video to clear my doubts. Thank you sir for making such an video with easy understanding with proof😊😊😊😊😊

AayushRajesh-xrkk