Created
March 15, 2012 19:21
-
-
Save Linusstrom/2046229 to your computer and use it in GitHub Desktop.
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 ReverseArray { | |
public static void main(String[] args) | |
{ | |
double[] array = new double[4]; | |
array[0] = 5.0; | |
array[1] = 1.1; | |
array[2] = 3.2; | |
array[3] = 2.3; | |
//for(int i = 0; i < array.length; i++) | |
for(int i = 0; i < array.length/2; i++){ | |
double swap = array[array.length - 1 - i]; | |
array[array.length - 1 - i] = array[i]; | |
array[i] = swap; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment