Question: JAVA homework. Thank you public static void main(String[] args) { if (args.length < 1) { Errors.fatal( Missing filename argument ); } else if (args.length >

JAVA homework. Thank you

 public static void main(String[] args) { if (args.length < 1) { Errors.fatal( "Missing filename argument" ); } else if (args.length > 1) { Errors.fatal( "Unexpected extra arguments" ); } else try { readNetwork( new Scanner( new File( args[0] ) ) ); } catch (FileNotFoundException e) { Errors.fatal( "Can't open file '" + args[0] + "'" ); } } 

Background: The notes for Lecture 6 suggest having a call to Errors.fatal() if there are extra arguments, but the code doesn't tell the user about the extra arguments it found. In contrast, the call to Errors.fatal() given for a file that can't be opened gives useful feedback.

a) Suggest simple code for the error message for extra arguments that shows the first extra argument. (0.4 points)

b) Briefly explain why part a above only asked for the first extra argument. (You might try working out the code you'd have to write if you wanted the message to show all the extra arguments, but do not turn in this code, just explain what about that code made it unappealing in this context.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!