.print()
Published Jun 25, 2022
Contribute to Docs
The .print()
method prints its argument to the console. Unlike the similar .println()
method, .print()
does not follow its argument with a new line, and any subsequent characters sent to the console will begin wherever the prior .print()
command left off.
Syntax
System.out.print(argument);
The argument
passed to the print()
method will be displayed on the console.
Example
The following example prints some content to the console (Note: if there is to be any spacing between uses of .print()
it must be accounted for in the arguments.):
public class PrintExample {public static void main(String[] args) {System.out.print("Output");System.out.print(123.456);System.out.print(true);}}
This results in the output:
Output123.456true
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.