我试图在我的程序中实现这个微小的方面,但它真的让我很难在最小的东西上...
txtDay.getText().toUpperCase(); switch(txtEmployeeID.getText()){ case "54215": switch(txtDay.getText()){ case "SUNDAY": E54215.set(0, txtHours.getText()); break; case "MONDAY": E54215.set(1, txtHours.getText()); break; case "TUESDAY": E54215.set(2, txtHours.getText()); break; case "WEDNESDAY": E54215.set(3, txtHours.getText()); break; case "THURSDAY": E54215.set(4, txtHours.getText()); break; case "FRIDAY": E54215.set(5, txtHours.getText()); break; case "SATURDAY": E54215.set(6, txtHours.getText()); break; } break;
NetBeans在"txtDay.getText().toUppercase()"行中给出了一个错误,并告诉我"应检查方法返回值".
有人可以帮我找出为什么会出现这个错误吗?
这不是错误,而是警告.它表示您没有使用操作的结果.字符串是不可变的,你需要这样的东西:
txtDay.setText(txtDay.getText().toUpperCase());
得到你期望的结果.