Hallo!
Ich habe ein Stück code geschrieben, das über Methoden geht, ich hätte eigentlich gedacht, dass "Die umgedrehten Werte: 54321" rauskommt, aber anscheinend kommt nur "Die umgedrehten Werte: " raus, wenn man mir helfen könnte wäre ich glücklich.
Code:
package methoden;
public class SwappedCopy {
public static int[] swappedCopy(int[] copy){
for(int i=0, e=copy.length; i<copy.length;i++,e--){
copy[i]=e;
}
return copy;
}
public static int[] copy(int[] array){
int[] copy = new int[array.length];
for(int i=0; i<array.length;){
copy[i]= array[i];
}
return copy;
}
public static void main(String[] args) {
int[] array = new int[]{1,2,3,4,5};
System.out.println("Die umgedrehten Werte: ");
for(int i =0;i<swappedCopy(copy(array)).length;i++)
System.out.print(swappedCopy(copy(array))[i]);
}
}