How to reverse a string in Java without using the reverse method ?

How to reverse a string in Java without using the reverse method ?

Program
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		int x,n;
		String s;
		
		Scanner sc=new Scanner(System.in);
		System.out.println("Enter String :");
		s=sc.nextLine();
		n=s.length();
		for (x=n-1 ; x >= 0; x--)
	    {
	       System.out.print(s.charAt(x)); 
	    }
	}

}	

Output:

Enter String : sateeshm
hseetas





More Questions


15 . Write a java program How to check if two strings are anagrams of each other?
16 . How to reverse a string in Java without using the reverse method ?
17 . How to count the occurrence of the given character in a string?
18 . How to check if a string is a palindrome?
19 . How to count the number of words in a given string sentence?
20 . How to reverse the words from the given string sentence?
21 . How to swap two strings without using the third variable?