Browse Source

Remove first

secondBranch
lauraF 3 years ago
parent
commit
ed923d7fcc
  1. 16
      ArrayManipulation.java

16
ArrayManipulation.java

@ -13,17 +13,17 @@ public class ArrayManipulation {
return arr;
}
public static int[] removeLast(int[] arr) {
int[] result = new int[arr.length-1];
for (int i = 0; i < arr.length-1; i++) {
result[i] = arr[i];
}
return result;
}
public static void main(String[] args) {
int[] arr = {1,2,3,4,5};
System.out.println(Arrays.toString(reverseArray(arr)));
//Hallo ich verändere deinen Code
}
public static int[] removeFirst(int[] arr) {
int[] newArray = new int[arr.length];
for(int i = 1; i < arr.length; i++){
newArray[i-1] = arr[i];
}
return newArray;
}
}