Home  >  Article  >  Java  >  The difference between print and println in java

The difference between print and println in java

(*-*)浩
(*-*)浩Original
2019-11-11 09:45:0718460browse

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);
    }
}

Run result:

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

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!

Statement:
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
Previous article:How to run java filesNext article:How to run java files