如果该字符没有出现,则此方法返回该字符串在指定字符首次出现时的索引,或者为-1。
int indexOf(int ch) - 语法
public int indexOf(char ch)
这是参数的详细信息-
ch - 一个字符。
int indexOf(int ch) - 示例
import java.io.*; public class Test { public static void main(String args[]) { String Str=new String("Welcome to Learnfk.com"); System.out.print("Found Index :" ); System.out.println(Str.indexOf( o )); } }
这将产生以下输出-
Found Index :4