Reverse String

Write a program to reverse a string.

import java.io.*;
import java.util.*;

public class Main {
	public static void main (String[] args) {
	    
		String str= "mukesh", revstr="";
		char ch;
	for (int i=0; i<str.length(); i++)
	{
		ch= str.charAt(i);  
		revstr= ch+revstr; 
	}
	System.out.println(revstr);
	}
}

Leave a Reply

Your email address will not be published. Required fields are marked *