Description: As a young jedi you must learn to converse with Yoda. You have found a simple rule that helps change a “normal” sentence into “Yoda talk”. Take the first two words in the sentence and place them at the end. Write a program that uses this rule to change normal sentence into “Yoda talk”.
Input:
Input consists of a string that you must change into “Yoda talk”.
Assume that the maximum length of the string is 100;
Output:
Print the corresponding sentence in Yoda talk.
Sample Input:
I will go now to find the Wookiee
Sample Output:
go now to find the Wookiee I will
Solution
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
String str1, sentence = "";
str1 = s.nextLine();
String[] str2 = str1.split("\\s");
for (int i = 2; i < str2.length; i++) {
sentence += str2[i] + " ";
}
sentence += str2[0] + " " + str2[1];
System.out.println(sentence);
}
}Happy Learning – If you require any further information, feel free to contact me.
![[Solved] YODA String with Java [Solved] YODA String with Java](https://realcoder.techss24.com/wp-content/uploads/2022/07/Solved-YODA-String-with-Java.png)

![[Solved] Adjacent Stick Game with Java, C++, Python](https://realcoder.techss24.com/wp-content/uploads/2022/07/Solved-Adjacent-Stick-Game-with-Java-C-Python-300x200.png)
![[Solved] Character Pattern 8 with Java, C++](https://realcoder.techss24.com/wp-content/uploads/2022/07/Solved-Character-Pattern-8-with-Java-C-300x200.png)