Program To Print a String In Reverse Order :
import java.util.Scanner;
public class Gndec
{
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
String name,rev="";
System.out.println("Enter Your Name");
name=input.nextLine();
System.out.printf("Hello,%s\nIn reverse Order :",name);
int j=0,n=name.length();
for(int i=n-1;i>=0;i--)
{
rev=rev+name.charAt(i);
}
System.out.println(rev);
}
}
Output:
import java.util.Scanner;
public class Gndec
{
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
String name,rev="";
System.out.println("Enter Your Name");
name=input.nextLine();
System.out.printf("Hello,%s\nIn reverse Order :",name);
int j=0,n=name.length();
for(int i=n-1;i>=0;i--)
{
rev=rev+name.charAt(i);
}
System.out.println(rev);
}
}
Output: