Question Index

Write a program to reverse each word in a sentence. There should not be any extra spaces at the end.

Input (String) Output (Integer)
I love mom I evol mom
I like my brother I ekil ym rehtorb
Sun rises in the east nuS sesir ni eht tsae
Learn Java with Merit Campus nraeL avaJ htiw tireM supmaC

class ReverseEachWordInASentence
    public static void main(String s[])
        String sentence = "I love mom";
        System.out.println("After reversing each word : " + reverseEachWord(sentence));


    public static String reverseEachWord(String sentence) {




Topic: Java StringBuffer, reverse() - Reverse A String In Java

Read this topic
Take test on this topic

Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App