目录

int indexOf(int ch, int fromIndex)

描述 (Description)

此方法返回指定字符第一次出现的此字符串中的索引,在指定索引处开始搜索,如果未出现该字符,则返回-1。

语法 (Syntax)

以下是此方法的语法 -

public int indexOf(int ch, int fromIndex)

参数 (Parameters)

这是参数的细节 -

  • ch - 一个角色。

  • fromIndex - 从中开始搜索的索引。

返回值 (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', 5 ));
   }
}

这将产生以下结果 -

输出 (Output)

Found Index :9
↑回到顶部↑
WIKI教程 @2018