目录

int lastIndexOf(String str)

描述 (Description)

此方法接受String作为参数,如果字符串参数作为此对象中的子字符串出现一次或多次,则返回返回的最后一个子字符串的第一个字符的索引。 如果它不作为子字符串出现,则返回-1。

语法 (Syntax)

以下是此方法的语法 -

public int lastIndexOf(String str)

参数 (Parameters)

这是参数的细节 -

  • str - 一个字符串。

返回值 (Return Value)

  • 此方法返回索引。

例子 (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.print("Found Last Index :" );
      System.out.println( Str.lastIndexOf( SubStr1 ));
   }
}

这将产生以下结果 -

输出 (Output)

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