System.out.print() vs System.out.println()

https://www.codecademy.com/courses/learn-java/lessons/learn-java-manipulating-variables/exercises/introduction?action=resume_content_item

I noticed when I typed in System.out.print(), Codeacademy said it was incorrect, yet, when I put in System.out.println(), it was correct.

I know that the difference between the two is that print() will print the output all in one line, like this:
hello world

While println() will print the output by seperating the lines, like this:
hello
world

Are there any differences I need to know between those two specifically in terms of variables as well as in a more general scope of Java programming

Edit: I noticed this has been happening throughout the “manipulating variables” unit. Which one and when do you use the two?

Which one to use would be strictly a matter of preference or whichever is best suited to your desired outcome out in the real world. In the context of a Codecademy lesson, you have to use the one specified. If neither is specified, you may still only have one or the other accepted by the SCT that checks your code. Frequently in all Codecademy lessons there is only one specific solution accepted by the SCT. After submitting the acceptable answer, you are free to play around with the code, and see what else will also work. Hope this helps!

Did you use ; after () for example System.out.println(“Hello world”); for text and System.out.println(VARIABLE); to print variables

Hello estorliao, welcome to the community :+1:

You need to use ; after every line of code unless it:
ends in a bracket, which means it closes something.
is a comment, which is done with // and /* */
is written in the terminal, where some commands are not java.

Hope this helps you! :smile: :smile: