Skip to content

Instantly share code, notes, and snippets.

Created March 3, 2013 19:58
Show Gist options
  • Save anonymous/5077996 to your computer and use it in GitHub Desktop.
Save anonymous/5077996 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class FirstFour {
public static void main(String [] args)
{
String word;
System.out.println("Enter a word here");
Scanner in = new Scanner(System.in);
word = in.nextLine();
System.out.println("The reverse is:" + wordArray);
}
public void reverse(String word)
{
char[] wordArray = word.toCharArray();
int i = 0;
int j = wordArray.length-1;
while (i < j)
{
char b = wordArray[i];
wordArray[i] = wordArray[j];
wordArray[j] = b;
i++; j--;
}
System.out.println("The reverse is:" + wordArray);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment