Reverse the string Program in java

Simple program to reverse the string in java. This logic, also used to check whether the given string is palindrome or not. By comparing string after reversing it.

class reverseProgram {
    public static void main(String args[])  {

String reverse=” “;
String original=”Techie Tet”;
int len=original.length();
for(int i=len-1;i>=0;i--)
  {
reverse=reverse+original.charAt(i);
 }
System.out.println(reverse);

}
}

 

Also refer how to reverse a string in java using string buffer. And difference between string buffer and string builder, these type of questions are mostly asked in interviews.

 

 

Program to reverse each word in a string, not the whole sentence. Above program is to reverse the whole sentence.

Program to check palindrome.