Write a program for a Reverse of a String
import java.util.Scanner; public class StringReverse { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println("Enter a String"); String str=sc.nextLine(); int strLen=str.length(); char c[]=new char[20]; for(int i=0,j=strLen-1;i<strLen;i++,j--) { c[i]=str.charAt(j); System.out.print(c[i]); } } } OUTPUT:- Enter a String vinodh bandu udnab hdoniv
No comments:
Post a Comment