关于java中indexof的问题

[复制链接]
查看11 | 回复2 | 2021-1-27 06:32:07 | 显示全部楼层 |阅读模式
先贴出实验代码:
publicclassTest{
publicstaticvoidmain(String[]args){
Stringoptstr="adasjjas.kdfg";
Stringresult=indexOfAll(optstr,"as");
System.out.println(result.equals("2,6"));
}
publicstaticStringindexOfAll(Stringoptstr,Stringstring){
待填补代码;
returnnull;
}
}
而我自己写的填补代码在下面一直报错运行不出来,填补的代码是要实现main方法里面的indexOfAll方法求教大佬指点怎么写
inta[]=null;
while(optstr!=null){
for(inti=0;i -->
回复

使用道具 举报

千问 | 2021-1-27 06:32:07 | 显示全部楼层


Stringstr=optstr.indexOf("as")+","+optstr.lastIndexOf("as");
returnstr;
回复

使用道具 举报

千问 | 2021-1-27 06:32:07 | 显示全部楼层
你的a数组是空。。。。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行