+ 4
what is difference between these syntax in java: System.out.print("*"); and System.out.println("*");
tell the difference between these syntax in java: System.out.print("*"); and System.out.println("*");
5 Answers
+ 9
//in actual no difference will be there in the output of the code if u use only 1 print statement
//but when u print multiple lines using these u will see the difference in the output by ur own
//1)
System.out.print("*"); System.out.print("*");
//output **
//2)
System.out.println ("*");System.out.println("*");
//output *
*
+ 3
System.out.print will not print a new line after it is called. System.out.println will print a new line.
System.out.print("*");
System.out.print("_");// prints *_
System.out.println("*");
System.out.println("_"); // prints *
// _
+ 2
println = Print and include a line break (enter)
print = print and keep the cursor on the same line
+ 2
thanks @ Gaurav ,Zeke, Xeroxis, Amrit Mahendra.
+ 1
System.out.print() does not break the line.
System.out.println() breaks the line.