0
Guys why it isn't working
Link : https://code.sololearn.com/cgWS7doGFYOS/?ref=app Output : "OlĂĄ,Mundo!OlĂĄ Java"
6 Answers
+ 2
public class Program
{
public static void main(String[] args) {
System.out.print("OlĂĄ,Mundo!");
System.out.println("\nOlĂĄ Java");
}
}
Cat Raspberry đ„§ do this
+ 2
Print will print it in same line. And println will print it in same line and then take the cursor down
+ 1
It's working fine tell your excepted output
+ 1
System.out.println() adds new line after output.. while System.out.print method does not add new line...
edit:
see differences ,
from search bar:
https://www.sololearn.com/discuss/1317561/?ref=app
https://www.sololearn.com/discuss/1515132/?ref=app
+ 1
Cat Raspberry đ„§
.print() don't do a line break
.print("hello");
.print("test");
-> on same line
.println("another test");
-> still on same line but the next statement will be printed on the next line
.println("next");
So in your case:
.print("OlĂĄ,Mundo!");
.println() //for line break
.println("OlĂĄ Java");
or much easier: just use println() if you want to print everything on a new line.
0
Atul
Output that i want :
OlĂĄ,Mundo!
OlĂĄ Java
But he printed just in the first line