title: How do I use Scanner to read in a series of Strings from the keyboard, all on one line, and concatenate them
body: <p>How do I use Scanner to read in a series of Strings from the keyboard, all on one line, and concatenate them.</p>
  
  <p>Here is the code I have so far:</p>
  
  <pre><code>import java.util.Scanner;
  
  public class Exam12Practice {
  
     public static void main(String[] args) 
     {
        Scanner input=new Scanner(System.in);
        String words="";
        System.out.println("enter a word");
        while(input.hasNext())
        {
           words = words.concat(input.next());
        }
  
        System.out.println(words);
     }
  }
  </code></pre>