Java Program:

- To reverse a string

Example:

User Input: Hello World

Output: dlroW olleH

import java.util.Scanner;
public class ReverseString {
  public static void main(String []args) {
    String s1,reverse="";
    Scanner userInput = new Scanner(System.in);
    System.out.print("Enter Your string : ");
    s1 = userInput.nextLine();

    int l=s1.length()-1;
    while(l!=-1) {
      reverse+=s1.charAt(l--);
    }

    System.out.println("Your reversed string : "+reverse);
  }
}

Output:

  Enter Your string : fun with code
  Your reversed string : edoc htiw nuf
Program
string

Main Logic :

// varibale 'l' holds length of string - 1 (since index starts from 0)
while(l!=-1) {
  reverse+=s1.charAt(l--);
}
Concept

Coming Soon !

Quick
Tutorial

Quote

Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning.