如何在字符串中查找indexof [英] How to find indexof in a string
本文介绍了如何在字符串中查找indexof的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public static void main( String [] args){
// TODO自动生成的方法存根
字符串 str = 567890432;
dd d = new dd();
System.out.println(d.findindexof(str, 2 ));
// 索引2处的值为6
}
public int findindexof( String str, int a){
for ( int i = 0 ; i< str.length(); i ++){
if (){}
// 代码是什么在这里
}
返回 0 ;
}
}
解决方案
为什么重新发明轮子?
Java - String indexOf()方法 [ ^ ]
public static void main( String [] args){
// TODO自动生成的方法存根
字符串 str = 567890432;
dd d = new dd();
系统。 out .println( str.indexOf( 6 ));
// 索引2处的值为6
}
public static void main(String[] args) {
// TODO Auto-generated method stub
String str = "567890432";
dd d = new dd();
System.out.println(d.findindexof(str, 2));
// value at index 2 is 6
}
public int findindexof(String str, int a) {
for (int i = 0; i < str.length(); i++) {
if(){}
//what would be code over here
}
return 0;
}
}
解决方案
Why Reinvent The Wheel?
Java - String indexOf() Method[^]
public static void main(String[] args) { // TODO Auto-generated method stub String str = "567890432"; dd d = new dd(); System.out.println(str.indexOf(6)); // value at index 2 is 6 }
这篇关于如何在字符串中查找indexof的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文