Write a program to reverse a String (don't use any predefined methods of string class)?

import java.util.Scanner;

public class StringReverse {
	static String inputString = "";

	public static void main(String args[]) {

	public static void getValue() {
		Scanner scan = new Scanner(System.in);
		System.out.println("Enter a String :");
		inputString = scan.nextLine();

	public static void reverse() {
		if (inputString == null || inputString.isEmpty()) {
			System.out.println("Please enter a valid string");

		String reverse = "";

		for (int i = inputString.length() - 1; i >= 0; i--) {
			reverse = reverse + inputString.charAt(i);

		System.out.println("Reverse is: " + reverse);

Enter a String : apple Reverse is: elppa Enter a String : earth Reverse is: htrae

Related Examples

Write a program to check if an input String is Palindrome or not?
Calculate the factorial of a given number using Java?
How to reverse a number in Java?
Write a program to convert from decimal to binary?
Producer Consumer Example in Thread
Write a program to reverse a String?

Receive Latest Java Examples in Your Email: