package practice;public class practice6{ private static int dayNumber; private int way; private static double sum; private static int[] number1={2,3,4,2,3,1}; private static int[] number2={2,5,4,1,0,1}; public void jisuan(int way){ switch(way){ case 1:new practice6().jisuan1();break; case 2:new practice6().jisuan2();break; } } public static void jisuan1(){ int dixin=dayNumber*40; int tichen=0; for(int a=0;a<=number1.length;a++){ tichen=5*number1[a]; } sum=dixin+tichen; } public static void jisuan2(){ int dixin=dayNumber*50; double tichen=0; for(int a=0;a<=number1.length;a++){ tichen=3*number1[a]; } sum=dixin+tichen; } public static void main(String[] args) { practice6 p6=new practice6(); p6.jisuan(2); }}
2 回答
望远
TA贡献1017条经验 获得超1032个赞
for(int a=0;a<=number1.length;a++){ tichen=5*number1[a]; }
for(int a=0;a<=number1.length;a++){ tichen=3*number1[a]; }
数组下标越界
for(int a=0;a<number1.length;a++){ }
下标是从0--length-1的length个元素下标
添加回答
举报
0/150
提交
取消