0
Guys why it isn't working
Link : https://code.sololearn.com/cgWS7doGFYOS/?ref=app Output : "Olá,Mundo!Olá Java"
6 ответов
+ 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