int indexOf(int ch)
描述 (Description)
如果未出现该字符,则此方法返回指定字符第一次出现的字符串中的索引或-1。
语法 (Syntax)
以下是此方法的语法 -
public int indexOf(char ch)
参数 (Parameters)
这是参数的细节 -
ch - 一个角色。
返回值 (Return Value)
- See the description.
例子 (Example)
import java.io.*;
public class Test {
public static void main(String args[]) {
String Str = new String("Welcome to iowiki.com");
System.out.print("Found Index :" );
System.out.println(Str.indexOf( 'o' ));
}
}
这将产生以下结果 -
输出 (Output)
Found Index :4