println and print the difference

------------ ------------ restore content begins

println and print differences:

1, print output after not wrap, as follows:


public class Newstart {
    public static void main(String[] args) {
        int x = 1;
        while(x<3) {
            System.out.print("Doo");
            System.out.print("Bee");
            x++;
        }
        if(x==3) {
            System.out.print("Do");
        }
    }
    
}

Output: DooBeeDooBeeDo

2, println output after wrapping lines, as follows:


public class Newstart {
    public static void main(String[] args) {
        int x = 1;
        while(x<3) {
            System.out.println("Doo");
            System.out.println("Bee");
            x++;
        }
        if(x==3) {
            System.out.println("Do");
        }
    }
    
}
输出:

Doo
Bee
Doo
Bee
Do

 

End ------------ ------------ restore content

Guess you like

Origin www.cnblogs.com/ouyangbo12/p/12111262.html