-8

I have a String str="Ram Is A Good Boy";

I want the output

Boy Good A Is Ram

Please give me a code for this approach??

subodh
  • 6,136
  • 12
  • 51
  • 73
user2142897
  • 21
  • 1
  • 2

3 Answers3

0

Not giving the direct solution but if you follow the steps below, you'll achieve what you want.

  1. split with space.
  2. print the splitted values in reverse order.

But on second thought your mirror image is wrong.

Ram Is A Good Boy | yoB dooG A sI maR

isn't that correct mirror for the given string?

Azodious
  • 13,752
  • 1
  • 36
  • 71
0
String str = "Ram Is A Good Boy";
String [] strArray = str.split(" ");
StringBuilder sb = new StringBuilder();
for(int i=strArray.length-1;i>-1;i--)
{
    sb.append(strArray[i]+" ");
}
System.out.println(sb.toString());
Michaël
  • 3,679
  • 7
  • 39
  • 64
subodh
  • 6,136
  • 12
  • 51
  • 73
0
String str="Ram Is A Good Boy";
String splits[] = str.split(" ");
string reverse = "";
for(int i = splits.length-1; i>=0; i--) {
    reverse += splits[i] + " ";
}
System.out.println(reverse);
Michaël
  • 3,679
  • 7
  • 39
  • 64