..  println(x)

Print (using :func:`print`) ``x`` followed by a newline.


In the Julia programming language, the println function is used to print the value of an expression followed by a newline character.

  1. Print a string:

    julia> println("Hello, World!")
    Hello, World!

    This example prints the string "Hello, World!" and adds a newline character at the end.

  2. Print numerical values:

    julia> x = 10
    julia> y = 20
    julia> println(x + y)

    Here, the sum of x and y is printed, resulting in 30.

  3. Print multiple values:

    julia> a = 5
    julia> b = 2.5
    julia> c = "Julia"
    julia> println(a, " + ", b, " is ", c)
    5 + 2.5 is Julia

    In this example, the values of a, b, and c are printed along with some additional text.

Common mistake example:

julia> x = [1, 2, 3]
julia> println(x)
[1, 2, 3]

In this case, if you mistakenly pass an array to println, it will print the array as a whole instead of printing its individual elements. If you want to print the elements separately, you can use the join function or a loop to iterate over the array and print each element individually.

See Also

:@printf, :@sprintf, display, displayable, dump, info, isprint, print, println, print_escaped, print_joined, print_shortest, print_unescaped, print_with_color, pushdisplay, redisplay, show, showall, showcompact, sprint, versioninfo,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field

Checking you are not a robot: