Hey I'm totally finished with my try-catch block, but have question. I want to count how many words and numbers a string contains. For this i want to use a try - catch block. I parse the String to an int, and if the output is false, I want to count the number of words within the catch block logic. But after the program enters the catch block, the program exits. I want to continue iterating through the loop following the caught error. How can I make this happen?
Scanner odczyt = new Scanner(System.in);
String zdanie = odczyt.nextLine();
String[] podzdania = zdanie.split(" ");
boolean exception = false;
int numberword = 0;
try {
for (int i = 0; i < podzdania.length; i++) {
Integer.parseInt(podzdania[i]);
}
} catch (NumberFormatException e) {
numberword++;
}