Java Program to reverse each word in String
Java Program to reverse each word in String
For Explanation watch the video
import java.io.*;
import java.util.*;
class Test{
public static void main(String[] args){
String s = "How are You?";
String[] arr = s.split(" ");
String res = "";
for(int i=arr.length-1;i>=0;i--){
res = res + arr[i] + " ";
}
System.out.println(res);
}
}