I'm trying to write a method that expects an array of int and two intS parameters, which represent the starting position and ending position of a subarray within the parameter array.
So here's the code I've written, trying to do this, but I'm getting errors having to do with the parameter passing. I don't think I'm doing it quite right, clearly...
I aim for the output of '10 11 12'.
Please help!
public class testing{ public static void main(String args[]) { int[]firstArray = {8, 9, 10, 11, 12, 13}; //original string subArray(int[]firstArray, 2, 4); //trying to pass these parameters to method subArray public static void subArray (int[]originalArray, int S2, int S2) //parameters - trying to get from previous line. { int[] copy = new int[3] //Instantiating new array to fill with contents from original array. System.arraycopy(originalArray[], 1, copy[], 0, 3); //copying over contents... for (int i = 0; i < copy.length; i++){ System.out.println(copy[i]);} // Will produce contents of new array 'copy' } }}