Home > Java > Javagetting Started > body text

The difference between print and println in java

(*-*)浩
Release: 2019-11-11 09:45:07
Original
18564 people have browsed it

The difference between print and println in java

The difference between print\println (Recommended learning: java course)

print will use its parameters Displays in the command window and positions the output cursor after the last character displayed.

println displays its parameters in the command window, adds a newline character at the end, and positions the output cursor at the beginning of the next line.

For example:

package other;
public class TestPrint {
    public static voidmain(String[] args) {
        int i = 4;
        double j = 5;
        System.out.print("用print输出i:"+ i);
        System.out.println( "用println输出i:"+ i);
        System.out.print("i的值为"+i+",j的值为"+j);
    }
}
Copy after login

Run result:

用print输出i:4用println输出i:4
i的值为4,j的值为5.000000
Copy after login

The above is the detailed content of The difference between print and println in java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template