如果该字符没有出现,则此方法返回该字符串在指定字符首次出现时的索引,或者为-1。
public int indexOf(char ch)
这是参数的详细信息-
链接:https://www.learnfk.comhttps://www.learnfk.com/java/java-string-indexof.html
来源:LearnFk无涯教程网
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
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)