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!