
Write a function that accepts a sentence as a parameter, and returns the same with each of its words reversed. The returned sentence should have 1 blank space between each pair of words. Demonstrate the usage of this function from a main program. Example: Parameter: ?jack and jill went up a hill? Return Value: ?kcaj dna llij tnew pu a llih?

Java Reverse words of sentence
import java.util.*;
public class ReverseString{
public static void main(String[]args){
Scanner input=new Scanner(System.in);
StringBuffer buffer=new StringBuffer();
System.out.println("Enter string: ");
String str=input.nextLine();
StringTokenizer stk=new StringTokenizer(str);
while(stk.hasMoreTokens()){
String st=stk.nextToken();
String reverse = new StringBuffer(st).reverse().toString();
buffer.append(reverse);
buffer.append(" ");
}
System.out.println("Reverse: " + buffer.toString());
}
}