User Program Communication

Print in Java

Printing is used to output text directly to the console.

System.out.print("Put your text here!" + variable); //assuming variable is declared
System.out.println("Put your text here!" + variable); //automatically adds a new line


All non-string variables that can be displayed as a string will be converted to string automatically.

Strings and variables are concatenated using a plus sign.

String name = "Hans";
System.out.println("Hello, " + name + "!"); //Will output Hello, Hans!

See Also

Java Docs - Formatting

Add to Slack

< HashSets   |   User Input >

© 2019 SyntaxDB. All Rights Reserved.