android开发:java.lang.ArrayIndexOutOfBoundsException: length=3; index=4

xingxing414 2019-06-27 06:13:57
private void infoss() {
final Calendar c = Calendar.getInstance();// 获取当前系统日期
int mYear = c.get(Calendar.YEAR);// 获取年份
int mMonth = c.get(Calendar.MONTH);// 获取月份
int mDay = c.get(Calendar.DAY_OF_MONTH);// 获取天数

//updateDisplay();// 显示当前系统时间
double[] str_monryInfos =new double[50];// 定义字符串数组,用来存储支出信息
String[] str_timeInfos=new String[50];
OutaccountDAO outinfo = new OutaccountDAO(Outaccountinfo.this);// 创建OutaccountDAO对象
// 获取所有支出信息,并存储到List泛型集合中
List<Tb_outaccount> listoutinfos = outinfo.getScrollData(0, (int) outinfo.getCount());
//strmonryInfos = new double[listoutinfos.size()];// 设置字符串数组的长度
//strtimeInfos=new String[listoutinfos.size()];
int i = 0;// 定义一个开始标识
for (Tb_outaccount tb_outaccount : listoutinfos) {// 遍历List泛型集合
// 将支出相关信息组合成一个字符串,存储到字符串数组的相应位置
str_monryInfos[i] = tb_outaccount.getMoney();
str_timeInfos[i]= tb_outaccount.getTime();
i++;// 标识加1
}
int[] strmonth=new int[50];
int[] strday=new int[50];
for(int j=0;j<str_timeInfos.length;j++){
String[] str=str_timeInfos[j].split("-");
for(int m=0;m<3;m++){
int a=Integer.parseInt(str[i]);
if(m==1){
strmonth[j]=a;
}
if(m==2){
strday[j]=a;
}
}
}
double sum_month=0;
for(int s=0;s<str_timeInfos.length;s++){
if(mMonth==strmonth[s]){
sum_month=sum_month+str_monryInfos[s];
}
}
if(sum_month==500){
send("5554","您当月的支出已达到上线500元");
}
double sum_day=0;
for(int s=0;s<str_timeInfos.length;s++){
if(mDay==strmonth[s]){
sum_day=sum_day+str_monryInfos[s];
}
}
if(sum_day==50){
send("5554","您当天的支出已达到上线50元");
}
...全文
238 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
usecf 2019-06-28
  • 打赏
  • 举报
回复
数组越界了 看看你代码那块范围有问题

80,362

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧