Assignment Content material
Utilizing the instance code for the generic PrintArray that was introduced in school (additionally supplied under), modify the code to overload the generic technique of PrintArray twice for every of the next:
take two extra integer arguments, high and low, entered by the person. Once you name the tactic with these arguments, it prints out solely the portion of the array that’s between the 2 subscripts. Your program must validate that the high and low are throughout the vary of the array bounds. If both is out of vary, then the overloaded PrintArray technique ought to throw and InvalidSubscriptException; The exception must be caught by the primary program and an error message to the person ought to notify them of the difficulty and permit them to enter an accurate worth. If no exception is thrown, then printArray ought to return the variety of parts printed. This can be a customized exception. The code for the exception class is supplied under the PrintArray code.
Overload the generic PrintArray with a non-generic model of the tactic that particularly prints an array of Strings (you may make up your individual names to make use of within the array) in neat, tabular format as proven under:
The next names are within the array;
Tom Abdul Han Mark
Sara Hamilton Anna Tatiana
You’ll need to change the primary program to train all variations of the overloaded technique. For the addition of two integer arguments, you could train each variations of printArray on all three array varieties (integer, double, and character). For the non-generic model, you could present the flexibility to train the tactic and print out the properly formatted string array content material.
Ensure to submit your java code file(s) and your execution screenshots. Do not forget to incorporate a program header along with your identify, part, task title, and an outline of this system. The execution screenshots are required for credit score. Ensure to submit your individual authentic code. SafeAssign has been enabled to confirm originality of code.
// Utilizing generic strategies to print array of various varieties.
public class GenericMethodTest
// generic technique printArray
public static < E > void printArray( E[] inputArray )
// show array parts
for ( E aspect : inputArray )
System.out.printf( “%s “, aspect );
System.out.println();
// finish technique printArray
public static void essential( String args[] )
// finish essential
// finish class GenericMethodTest
public class InvalidSubscriptException extends RuntimeException
// no-argument constructor
public InvalidSubscriptException()
// one-argument constructor
public InvalidSubscriptException(String message)
tremendous(message);
// two-argument constructor
public InvalidSubscriptException(String message, Throwable trigger)