sinat_33415638
sinat_33415638
2016-01-28 07:47

小白求助,为什么这段代码的case“2”未执行

  • switch

int j = 1;
int i = Integer.parseInt(source.getProperty("表单数据从第几行开始")) - 1;
int lastnum = getNum(source.getProperty("fileName"));
for (int k = 0; k < conditions.length; k++) {
System.out.println(conditions[k]);
switch (conditions[k]) {
case "1":
for (; i < lastnum; i++) {
XSSFRow readrow = readsheet.getRow(i);// 获取输入行
Process p = new ProcessRow();
if (p.panduan1(readrow)) {
System.out.println("get1");
XSSFSheet sheet = sc.getSheetAt(0);
XSSFRow outputrow = sheet.createRow(j++);
p.process1(readrow, outputrow);
p.process2(readrow, outputrow);
p.process3(readrow, outputrow);
p.process4(readrow, outputrow);
}
}
case "2":
for (; i < lastnum; i++) {
XSSFRow readrow = readsheet.getRow(i);// 获取输入行
Process p = new ProcessRow();
System.out.println("get");
if (p.panduan2(readrow)) {
System.out.println("get2");
XSSFSheet sheet = sc.getSheetAt(0);
XSSFRow outputrow = sheet.createRow(j++);
p.process2(readrow, outputrow);
}
}
default:
break;
}

        输出结果
        1

get1
get1
2
3
4
输入完毕

为什么case 2没执行

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

7条回答