How to Reverse String in Java ?

In using String method (split(“”)) for reverse String Which using the loop statements. Scanner is using for User Enter input . Example : “web query” “bew yreuq”.

import java.util.Scanner;
class rev
{
public static void main(String arg[])
{
Scanner sc=new Scanner(System.in);
System.out.println(” Enter the Paragarph “);
String str=sc.nextLine();
String ar[]=str.split(” “);
for(int i=0;i=0;j–)
{
System.out.print(ar[i].charAt(j));
}
System.out.print(” ” );
}

}

}

Amandeep kaur: Amandeep Kaur is passionate about programming and is working on Android development from her school days. She has worked on many open source projects and now part of Hoodu Digital solutions as a Android developer.