 |
 |
 |
| Class |
|
String |
 |
|
|
| Nome |
|
indexOf() |
 |
|
|
| Exemplos |
|
String str = "CCCP";
int p1 = str.indexOf("C");
int p2 = str.indexOf("P");
int p3 = str.indexOf("CP");
println(p1 + ":" + p2 + ":" + p3); // Prints '0:3:2'
|
|
|
| Descrição |
|
Tests to see if a substring is embedded in a string and returns the index position of the first occurance of the substring defined in the str parameter. If the str parameter is not found in the string, -1 is returned. |
 |
|
|
| Sintaxe |
|
indexOf(str)
indexOf(str, fromIndex)
|
 |
|
|
| Parâmetros |
|
| str |
|
String: the substring to search
|
| fromIndex |
|
int: the index from which to start the search
|
|
 |
|
|
| Retorno |
|
int |
 |
|
|
| Utilização |
|
Web & Applicações |
 |
|
|