Language
Version: SE 8
Categories
-
User Program Communication
-
Variables
-
Control Flow
-
Object Oriented Programming
-
String Class
User Program Communication
Print in Java
Printing is used to output text directly to the console.
Syntax
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
Notes
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.
Example
String name = "Hans";
System.out.println("Hello, " + name + "!"); //Will output Hello, Hans!