输入日期继续重复java
我一直在做这个任务 这是我的密码:输入日期继续重复java,java,date,user-input,Java,Date,User Input,我一直在做这个任务 这是我的密码: public void part2() { while (check) { try { System.out.println("Enter Payroll Period:\tSample: JAN-21-2016"); payperiod = input.nextLine(); period = payDate.parse(payperiod);
public void part2() {
while (check) {
try {
System.out.println("Enter Payroll Period:\tSample: JAN-21-2016");
payperiod = input.nextLine();
period = payDate.parse(payperiod);
payperiod = period.toString();
Scanner error = new Scanner(System.in);
String temp = "";
int count = 0;
char[] chtrs;
Path file = Paths.get("Employee.txt");
File location = new File(file.toString());
FileReader employeeFile = new FileReader(location);
BufferedReader lineReader = new BufferedReader(employeeFile);
List<String> except = new ArrayList<>(), holdLast = new ArrayList<>();
while ((temp = lineReader.readLine()) != null) {
int cont = 0;
for (char ime : temp.toCharArray()) {
char[] characters = new char[temp.toCharArray().length];
characters[cont] = temp.charAt(cont);
cont++;
}
except.add(temp);
count++;
}
for (int i = 0; i < except.toArray().length && i == except.toArray().length; i++) {
System.out.print("Enter number of days worked for " + except.toArray()[i] + ":\t");
int numDays = input.nextInt();
String thump = except.toArray()[i].toString() + " " + numDays;
System.out.println(thump + " <- dude its in");
holdLast.add(thump);
System.out.println(except + " <- check errors except\n holdLast -> " + holdLast);
check = false;
}
} catch (FileNotFoundException e) {
System.err.println("NO RECORD EXISTS!");
System.out.println("Create a new one first by choosing 1");
MidActExam4 token = new MidActExam4();
token.start();
} catch (IOException e) {
System.err.println(e.getMessage());
} catch (Exception e) {
System.err.println(e.getMessage() + e.getCause() + e.getStackTrace());
}
}
}
您永远不会进入内部循环,因此永远不会退出主循环:
for (int i = 0; i < except.toArray().length && i == except.toArray().length; i++) {
...
check = false;
}
因为条件i你可能是说我
for (int i = 0; i < except.toArray().length && i == except.toArray().length; i++) {
...
check = false;
}