|
|
@ -1,4 +1,4 @@ |
|
|
|
package bonusquiz; |
|
|
|
package ha01; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
|
|
|
@ -19,29 +19,27 @@ public class ArrayManipulation { |
|
|
|
public static int[] removeFirst(int[] arr) { |
|
|
|
|
|
|
|
int [] arrNeu = {}; |
|
|
|
arrNeu = new int[arr.length-1]; |
|
|
|
if(arr.length != 0) { |
|
|
|
arrNeu = new int[arr.length-1]; |
|
|
|
for (int i = 1; i < arr.length; i++) { |
|
|
|
arrNeu[i-1] = arr[i]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return arrNeu; |
|
|
|
} |
|
|
|
return arrNeu; |
|
|
|
|
|
|
|
} |
|
|
|
/*Erstellt ein neues Array ohne das letzte Element*/ |
|
|
|
public static int[] removeLast(int[] arr) { |
|
|
|
|
|
|
|
int [] arrNeu = {}; |
|
|
|
arrNeu = new int[arr.length-1]; |
|
|
|
if(arr.length != 0) { |
|
|
|
for (int i =0; i < arr.length -1; i++) { |
|
|
|
arrNeu[i] = arr[i]; |
|
|
|
arrNeu = new int[arr.length-1]; |
|
|
|
if(arr.length != 0) { |
|
|
|
for (int i =0; i < arr.length -1; i++) { |
|
|
|
arrNeu[i] = arr[i]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return arrNeu; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return arrNeu; |
|
|
|
} |
|
|
|
|
|
|
|
/*Erstellt ein neues Array wo alle Zahlen quadriert werden*/ |
|
|
|
|
|
|
@ -50,11 +48,10 @@ public class ArrayManipulation { |
|
|
|
int [] arrNeu = {}; |
|
|
|
arrNeu = new int[arr.length]; |
|
|
|
for (int i=0; i <arr.length; i++) { |
|
|
|
arrNeu[i] = arr[i] * arr[i]; |
|
|
|
arrNeu[i] = arr[i] * arr[i]; |
|
|
|
} |
|
|
|
return arrNeu; |
|
|
|
} |
|
|
|
return arrNeu; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|