import java.util.Scanner;
public class Reverse {
public static void main(String []argv)
{System.out.println("enter the string");
Scanner s1=new Scanner(System.in);
String s=s1.nextLine();
String a[]=s.split(" ");
String finalStr="";
for(int i = a.length-1; i>= 0 ;i--)
{
finalStr += a[i]+" ";
}
System.out.println("String before reverse -s => : " +s);
System.out.println("string after reversal of words => ");
System.out.println(finalStr);
s1.close();
}
}
public class Reverse {
public static void main(String []argv)
{System.out.println("enter the string");
Scanner s1=new Scanner(System.in);
String s=s1.nextLine();
String a[]=s.split(" ");
String finalStr="";
for(int i = a.length-1; i>= 0 ;i--)
{
finalStr += a[i]+" ";
}
System.out.println("String before reverse -s => : " +s);
System.out.println("string after reversal of words => ");
System.out.println(finalStr);
s1.close();
}
}
No comments:
Post a Comment