FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 101   



Following program shows you how to print given string in reverse order.

import java.util.Scanner;

public class StringOperations10 {

    public static void main(String[] args) {

        String input;
        String output = "";

        Scanner in = new Scanner(System.in);

        System.out.println("Please enter a string: ");

        input = in.nextLine();

        int length = input.length();

        for (int i = length; i > 0; i--)

            output = output + input.charAt(i - 1);

        System.out.println("Reverse of given string is: " + output);
    }
}

Output:

Please enter a string: 
hello
Reverse of given string is: olleh



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News