|
|
@ -18,6 +18,14 @@ public class ArrayManipulation { |
|
|
|
return square; |
|
|
|
} |
|
|
|
|
|
|
|
public static int[] removeFirst(int[] arr){ |
|
|
|
int[] firstRemoved = new int[arr.length -1]; |
|
|
|
for(int i = 0; i < firstRemoved.length; i = i + 1) { |
|
|
|
firstRemoved[i] = arr[i + 1]; |
|
|
|
} |
|
|
|
return firstRemoved; |
|
|
|
} |
|
|
|
|
|
|
|
public static int[] removeLast(int[] arr) { |
|
|
|
int[] lastRemoved = new int [arr.length - 1]; |
|
|
|
for (int i = 0; i < lastRemoved.length; i = i + 1) { |
|
|
@ -31,5 +39,6 @@ public class ArrayManipulation { |
|
|
|
System.out.println(Arrays.toString(reverseArray(arr))); |
|
|
|
System.out.println(Arrays.toString(squareEach(arr))); |
|
|
|
System.out.println(Arrays.toString(removeLast(arr))); |
|
|
|
System.out.println(Arrays.toString(removeFirst(arr))); |
|
|
|
} |
|
|
|
} |