Question: Find the Error Chapt 10 Starting Out With Java Early Objects 6E These are Java programs that I just need to find the errors and
Find the Error Chapt 10 Starting Out With Java Early Objects 6E
These are Java programs that I just need to find the errors and list them.
I do not necessarily need the program corrected just need the errors.
1. catch (FileNotFoundException e) {
System.out.println("File not found."); }
try {
File file = new File("MyFile.txt")
Scanner inputFile = new Scanner(file); }
2. // Assume inputFile references a Scanner object. try
{ input = inputFile.nextInt();
} finally {
inputFile.close(); }
catch (InputMismatchException e) {
System.out.println(e.getMessage()); }
3. try {
number = Integer.parseInt(str); }
catch (Exception e) {
System.out.println(e.getMessage()); }
catch (IllegalArgumentException e) {
System.out.println("Bad number format."); }
catch (NumberFormatException e) {
System.out.println(str + " is not a number."); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
