Created
October 31, 2011 06:22
-
-
Save ellbur/1327006 to your computer and use it in GitHub Desktop.
Reverse in place
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class reversereverse { | |
public static void main(String[] args){ | |
int[] data = {1, 2, 3, 4, 5, 6, 7, 8, 9}; | |
for (int i = 0; i<data.length/2; i++){ | |
int a = data[i]; | |
data[i] = data[data.length - i - 1]; | |
data[data.length - i - 1] = a; | |
} | |
System.out.println(java.util.Arrays.toString(data)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment