JavaNo Comments

default thumbnail

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(” ” );
}

}

}

Be the first to post a comment.

Add a comment