Answers for "how to reverse in java"

13

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));
Posted by: Guest on May-10-2020
1

reverse in jaav

// my linkedin : https://www.linkedin.com/in/vaalarivan-prasanna-3a07bb203/
list = new ArrayList<int> {3, 4, 7};  //initialising a list
Collections.reverse(list);  //reverses a List or an ArrayList
//now, list is {7, 4, 3}
Posted by: Guest on April-18-2021

Code answers related to "how to reverse in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language