arrays.reverse code example
Example 1: reverse array in java
int length = array.length;
for(int i=0;i<length/2;i++) {
int swap = array[i];
array[i] = array[length-i-1];
array[length-i-1] = swap;
}
or
Collections.reverse(Arrays.asList(array));
Example 2: javascript reverse array
var arr = [34, 234, 567, 4];
print(arr);
var new_arr = arr.reverse();
print(new_arr);
Example 3: how to reverse an array in javascript
array = [1 2, 3]
reversed = array.reverse()
Example 4: reverse array javascript
const list = [1, 2, 3, 4, 5];
list.reverse();
Example 5: reverse array java
for(int i=intArray.length-1;i>=0;i--)
System.out.print(intArray[i] + " ");
Example 6: reverse array in javascript
const reverseArray = arr => arr.reduce((acc, val) => [val, ...acc], [])