The difference between the output statement println() and print() in java

In java, both println() and print() statements are used to output content to the console. What is the difference between the two?

The println() statement will automatically change the line after outputting the information, and the output cursor will be positioned on the next line, and the parameters in the brackets () may not be filled.

The print() statement will not change the line after outputting the information, the output cursor is positioned after the character, and the parameters must be filled in the brackets ().

Example:

public class test1 {
    public static void main(String[] args) {

        System.out.println("a");
        System.out.print("b");
        System.out.print("c");
    }
}

output:

a

bc

Guess you like

Origin blog.csdn.net/kevinjin2011/article/details/129498246