Write a Program to reverse a String without using Predefined function

public class StringReverse{
     public static void main(String args[]){
        String name = "RAM";
        String ReverseString = "";
        char ch[] = name.toCharArray();
        for(int i= ch.length-1 ; i >=0 ; i--)
        {
            ReverseString =  ReverseString + ch[i];
        }
        System.out.println("Reverse of the String - " + ReverseString);
        
     }
}

Output: –

Reverse of the String - MAR

Leave a Reply

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