Search⌘ K
AI Features

Understanding the Code

Explore the fundamentals of Dart code by examining a Hello World example. Understand how print statements display output, the role of semicolons, and how comments help document your code. Learn imperative programming by seeing how instructions execute sequentially within the main function.

Overview

Just to refresh our minds, let’s take a look at the code for our Hello World application.

Dart
main() {
// Printing the text 'Hello World'
print("Hello World");
}

The Print Statement

On line 3 of the program, we are using a print statement which prints the text Hello World. print() is used to display the output of the code on the console. It follows this syntax:

Dart
print( Insert what you want to print here )

Since Hello World is text, to be able to print it, we need to enclose it in ...