Q:

How do you reverse a string character by character in java?

Let's say I have a string with the phrase "Bank of America". I want to reverse it so the output results in "aciremA fo knaB"
This is the code I have been trying to use but the output is only the last letter of the last word, which would be "a"
int position = phraseLength;
for(int index = position-1; index >= 0; index--);
System.out.println(p1.charAt(position-1));

I am not sure what is wrong here so any help would be appericated. 

A:

    StringBuffer sb=new StringBuffer("Bank of America");
    System.out.println(sb.reverse());

If you want to do it your way. use
    int position = phraseLength;
    for(int index = position-1; index >= 0; index--)
        System.out.println(p1.charAt(index));

A:

You have added an extra semicolon after for loop here
for(int index = position-1; index >= 0; index--);
                                                ^

Also you are always accessing the postion-i. You should access the index
System.out.println(p1.charAt(position-1));
                             ^^^^^^^^^^^
                                here

You can use this
int position = phraseLength;
for(int index = position-1; index >= 0; index--)
    System.out.print(p1.charAt(index));

or this
String output = "";
int position = phraseLength;
for(int index = position-1; index >= 0; index--)
    output+=p1.charAt(index);
System.out.println(output);

