Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

public class SubsetCopyArray { // TODO - write your code below this comment. //

ID: 3891490 • Letter: P

Question

 public class SubsetCopyArray {     // TODO - write your code below this comment.     // You will need to write a method that copies only     // a portion of the source array, given starting     // and ending indicies of that array.  The indicies     // are inclusive.  The method produces the copied array.      // DO NOT MODIFY printArray!     public static void printArray(String[] array) {         System.out.print("{");         if (array.length > 0) {             for (int x = 0; x < array.length - 1; x++) {                 System.out.print(array[x] + ", ");             }             System.out.print(array[array.length - 1]);         }         System.out.println("}");     }          // DO NOT MODIFY main!     public static void main(String[] args) {         printArray(subsetCopy(args,                               Integer.parseInt(args[0]),                               Integer.parseInt(args[1])));     } }

Explanation / Answer

public class SubsetCopyArray {

public static String[] subsetCopy(String[] source,int start,int end)

{

String[] copy=new String[end-start+1];

int k=0;

for(int i=start;i<=end;i++)

{

copy[k++]=source[i];

}

return copy;

}