问题描述
public static void main(String[] args) {
// your code goes here
Scanner sc=new Scanner(system.in);
int t=sc.nextInt();
while(t-->0){
String s=sc.next();
int count=0;
char[] str=s.tochararray();
for(int i=0;i<str.length;i++){
if(str[i]=='1' && str[i+ 1]!='1'){
count++;
}
}
System.out.println(count);
}
}
}
错误:
Exception in thread "main" java.lang.Arrayindexoutofboundsexception: 3
这是怎么回事!!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)