 <p><strong>Update</strong></p> <p>Use the split method of the String class to split the input string on the space character delimiter so you end up with a String array of words.</p> <p>Then loop through that array using a modified for loop to print each item of the array.</p> <pre><code>import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("Enter the sentence"); String sentence = in.nextLine(); showWords(sentence); } public static void showWords(String sentence) { String[] words = sentence.split(' '); for(String word : words) { System.out.println(word); } } } </code></pre>