package com.alok;
import java.util.Scanner;
public class String_reverse
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter String :");
String n=sc.nextLine();
String rev="";
int len=n.length();
for(int i=len-1;i>=0;i--)
{
rev=rev+n.charAt(i);
}
System.out.println("Reverse of Given String is :");
System.out.println(""+rev);
}
}
O/P:-
Enter String :
ALOK KUMAR
Reverse of Given String is :
RAMUK KOLA
good job
ReplyDeletehow to reverse without any api. i.e length() and charAt().
ReplyDelete