ciaodarwin
ciaodarwin

Reputation: 481

Input in the same line of the message (terminal)

Is there an Syntax that allows me to read the input from the user in the same line of the System.out.println() line?

Example:

What is your name?:(<-- Output)    Jack (<-- Input from user in the same line)   

Upvotes: 1

Views: 305

Answers (2)

Konstantin Yovkov
Konstantin Yovkov

Reputation: 62854

This should work for you.

System.out.print("What is your name?");

Upvotes: 4

David
David

Reputation: 20063

Use System.out.print instead of println

Then your next input will be on the same line.

Upvotes: 6

Related Questions