You can use Stack for solving such queries:
String input = "My name is Archit Patel";
Stack st = new Stack();
for(String word : input.split(" "))
st.push(word);
Iterator it = st.iterator();
while(it.hasNext()){
System.out.print(st.pop()+" ");
}
Output String: "Patel Archit is name My"