Note that there are some explanatory texts on larger screens.

plurals
  1. POCode fails when multiple words inputed
    text
    copied!<p>:D I'm completly new to Java and now I'm doing basic examples(with Java 1.7 and Eclipse IDE)</p> <p>I have tried the code below.It should take user inputs an them display them in the end.</p> <pre><code>package loop; import java.util.Scanner; public class MainClass { public static void main(String[] args) { // TODO Auto-generated method stub Scanner user_input = new Scanner( System.in ); String name; System.out.print("What is yout name?: "); name = user_input.next(); String quest; System.out.print("What is your quest?: "); quest = user_input.next(); String color; System.out.print("What is your favourite color?: "); color = user_input.next(); String sentence; sentence = "Your name is" + " " + name + " " + ",and your quest is" + " " + quest + " " + ",and your favourite color is" + " " + color; System.out.println(sentence); } } </code></pre> <p>and everything thing works fine when I use only one word for input like here</p> <pre><code>What is yout name?: Marko What is your quest?: seeking What is your favourite color?: green Your name is Marko ,and your quest is seeking ,and your favourite color is green </code></pre> <p>but everything fails with multiple words inputed:</p> <pre><code>What is yout name?: Marko Scekic What is your quest?: What is your favourite color?: seeking blue Your name is Marko ,and your quest is Scekic ,and your favourite color is seeking What is yout name?: Marko What is your quest?: seeking for Holy grail What is your favourite color?: Your name is Marko ,and your quest is seeking ,and your favourite color is for </code></pre> <p>I tried everything that is in my power(I replaced print with println and reversed,tried changing the order of the questions etc..).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload