Julia Output
Output is the text a program shows on the screen. Julia prints output with print and println, and the two commands differ in one small way.
print stays on the line and println ends it
The first two calls use print, so their text runs together. The third call uses println and ends the line.
print("One")
print("Two")
println("Three")
println("Four")Commas print several values in one call
One call prints three values here. The spaces come from the middle text value, not from the commas.
println("Ana", " is ", 31)println() prints an empty line
The middle call has nothing inside its parentheses. It leaves a blank line between the two words.
println("Above")
println()
println("Below")Example
print("Loading")
println(" done")
println("Name: ", "Ana")
println()
println("Finished")Key points
- Output: the text a program shows on the screen.
- println: prints values and then moves to a new line.
- print: prints values and stays on the same line.
- Use commas to print several values in one call.
- Spacing: commas add no space, so any space must be part of a printed text value.
- Empty line: println() with nothing inside prints an empty line.
In this example, print writes Loading and stays on the line, so the next println adds done beside it and ends the line. The next line prints a label and a name in one call. An empty println leaves a blank line, and the last line prints Finished.
Try it Yourself
Edit the code, then press Run.
Running is simulated · JuliaHub
Exercise
Which call prints an empty line?