Java .print()

StevenSwiniarski's avatar
Published Jun 25, 2022

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.

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn to code in Java — a robust programming language used to create software, web and mobile apps, and more.
    • Beginner Friendly.
      17 hours

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

All contributors

Learn Java on Codecademy

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn to code in Java — a robust programming language used to create software, web and mobile apps, and more.
    • Beginner Friendly.
      17 hours