I've tried this code but I am unsure as to why it does not work:
String[] arr = {"A", "B", "C", "D", "E"};//AD
String[] arr2 = arr;
int last = arr.length-1;
int first = 0;
int size = arr.length;
while (first < size) {
arr2[first] = arr[last];
last--;
first++;
}
System.out.print(Arrays.toString(arr2));
Can anybody help?
String[] arr2 = arr;doesn't make a copy. That's still the same array.