目录

int indexOf(String str)

描述 (Description)

此方法返回指定子字符串第一次出现的此字符串中的索引。 如果它不作为子字符串出现,则返回-1。

语法 (Syntax)

以下是此方法的语法 -

int indexOf(String str)

参数 (Parameters)

这是参数的细节 -

  • str - 一个字符串。

返回值 (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");
      String SubStr1 = new String("Tutorials");
      System.out.println("Found Index :" + Str.indexOf( SubStr1 ));
   }
}

这将产生以下结果 -

输出 (Output)

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