How do you print output in Java?

In Java, you can use the `System.out.println()` method to print output. This method sends the specified content to the console.

Here is a simple example demonstrating how to use Java to print output.

public class PrintOutputExample {

    public static void main(String[] args) {

        // 打印字符串

        System.out.println("Hello, World!");

        // 打印整数

        int num = 10;

        System.out.println("The number is: " + num);

        // 打印浮点数

        double pi = 3.14159;

        System.out.println("The value of pi is: " + pi);

    }

}

Running the above code will display the following output in the console.

Hello, World!

The number is: 10

The value of pi is: 3.14159

bannerAds