Skip to content

Instantly share code, notes, and snippets.

@arielmagbanua
Created September 16, 2021 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arielmagbanua/e6c797e08d8305bb9ac33caaa925230f to your computer and use it in GitHub Desktop.
Save arielmagbanua/e6c797e08d8305bb9ac33caaa925230f to your computer and use it in GitHub Desktop.
Reversed Sentence

Reverse Words

Write a Java program to reverse the words in a sentence.

Starter Code

public class App {
    public static void main(String[] args) throws Exception {
        // scanner
        Scanner scanner = new Scanner(System.in);

        // get the input sentence

        // split into words and reverse them
        
        // print the reversed sentence

        scanner.close();
    }
}

Output

Input a sentence: The quick brown fox
Reversed sentence: xof nworb kciuq ehT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment