Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Print Function in Dart | First Acquaintance with Dart
Introduction to Dart

bookPrint Function in Dart

To display information in the console, add text inside the parentheses of the print() function.

main.dart

main.dart

copy
123
void main() { print("Text you want to output"); }

If you want to output the text to the console, we must write it inside the quotation marks.

main.dart

main.dart

copy
123456
void main() { // The text can be written in single quotation marks print('Hi, Codefinity!'); // The text also can be written in double quotation marks print("I want know more"); }

The main rule when using the print() function is that it's important for the quotation marks surrounding the text to match on both sides. For example, if we use single quotes to print text ('like this'), we must close them with single quotes as well. This allows Dart to correctly recognize it as text to be printed, rather than a variable name or instruction. If the quotation marks do not match, or if they are absent altogether, it can lead to a runtime error in the program.

main.dart

main.dart

copy
123
void main() { print(2); }

Working with numbers differs from working with text. When displaying numbers, you don’t need to use quotes (" " or ' '), because numbers are treated as numeric values, not text.

question mark

Which statement correctly uses print() to display text or a number in Dart?

Select the correct answer

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 1. Kapitel 3

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

Awesome!

Completion rate improved to 4.55

bookPrint Function in Dart

Swipe um das Menü anzuzeigen

To display information in the console, add text inside the parentheses of the print() function.

main.dart

main.dart

copy
123
void main() { print("Text you want to output"); }

If you want to output the text to the console, we must write it inside the quotation marks.

main.dart

main.dart

copy
123456
void main() { // The text can be written in single quotation marks print('Hi, Codefinity!'); // The text also can be written in double quotation marks print("I want know more"); }

The main rule when using the print() function is that it's important for the quotation marks surrounding the text to match on both sides. For example, if we use single quotes to print text ('like this'), we must close them with single quotes as well. This allows Dart to correctly recognize it as text to be printed, rather than a variable name or instruction. If the quotation marks do not match, or if they are absent altogether, it can lead to a runtime error in the program.

main.dart

main.dart

copy
123
void main() { print(2); }

Working with numbers differs from working with text. When displaying numbers, you don’t need to use quotes (" " or ' '), because numbers are treated as numeric values, not text.

question mark

Which statement correctly uses print() to display text or a number in Dart?

Select the correct answer

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 1. Kapitel 3
some-alt