String is getting cut off in Java
<p>Whenever I process an input string with the Scanner and the string contains a space, only the first word appears. How can I adjust this so the entire phrase is entered into one string variable?</p>

<p>My code:</p>

<pre><code>import java.util.Scanner;

public class HelloWorld {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.print("Enter your name: ");
        String name = scan.next();
        String namefinal = name.replace(' ', '_');
        System.out.println(namefinal);
    }   
}
</code></pre>
