Q:

Java programming Input:Today is Sunday Output:Sunday is today

String str="Today is Sunday"
And the output should be "Sunday is Today"
I need a code for this program in Java.
Is there any other method to do it...

A:

This feels like a question for a university assignment, but in essence, you need to split the array then reverse it. 
 var elems = inStr.split(' ');
 elems.reverse();

Unless I'm misunderstanding the question.
For the record, JavaScript and Java are different languages, and I've written JavaScript.
EDIT: In Java, it's something like this:
 String inStr = "today is thursday";
 String[] elems = inStr.split("\ ");

You can then just loop backwards over the array.

