Skip to content

Instantly share code, notes, and snippets.

@Linusstrom
Created March 15, 2012 19:21
Show Gist options
  • Save Linusstrom/2046229 to your computer and use it in GitHub Desktop.
Save Linusstrom/2046229 to your computer and use it in GitHub Desktop.
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