Skip to content

Instantly share code, notes, and snippets.

@nsfyn55
Created August 25, 2012 21:03
Show Gist options
  • Save nsfyn55/3470967 to your computer and use it in GitHub Desktop.
Save nsfyn55/3470967 to your computer and use it in GitHub Desktop.
In Place Array Reverse
package com.art.samples.inplace_string_reverse;
/**
* Hello world!
*
*/
public class App
{
/**
* @param args
*/
public static void main( String[] args )
{
char[] in = {'1','2','3','4'};
System.out.println(in.length);
for(int i=0;i<in.length/2;i++){
char buff = in[i];
in[i] = in[in.length-1-i];
in[in.length-1-i] = buff;
}
System.out.println(in);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment