package practice1;
public class PrintStentenceWordbyWord {
public static void main(String[] args) {
String input="Sanjeevaiah Good Morning";
String[] words = input.split("\\s");
String invertedSentece = "";
for (String word : words){
String invertedWord = "";
for (int i = word.length() - 1; i >= 0; i--)
invertedWord += word.charAt(i);
invertedSentece += invertedWord;
invertedSentece += " ";
}
// invertedSentece.trim();
System.out.println("Inverted Sentence ::: "+invertedSentece);
}
}
No comments:
Post a Comment