This is a program to change the first word in a user input sentence with the last.
I am extremely sorry if this is a simple fix but I either get a repeated String or a printout error. I have been at it for days -_-
int first;
int last;
first = Modified.indexOf (' ');
last = Modified.lastIndexOf(' ')+1;
String word = Modified.substring(0,first);
String lastword = Modified.substring(first+1, last+4);
String Modified2 = Modified.replace(word, lastword);
System.out.println( Modified2);