Learn Dart Programming > 1. Getting Started > Write your first program

Write your first program

##Learn to write your first dart program Let us start with the simple “Hello World!” example -

void main(){
  print("Hello World!");
}

Output

hello World!

A dart program is composed of many other components. To make learning easier and fun we programmed above code. The main() function is a predefined method in Dart. This method acts as the entry point to the application. A Dart script needs the main() method for execution. print() is a defined function that prints the output be it string or other values to terminal.

An program is only gives output until and unless it is executed. You can execute a dart program in two ways-

  • Via the terminal
  • Via the WebStorm IDE

To execute through terminal

  • Go to terminal of the specific dart project and type your dart file name with the .dart extension.

    dart_file_name.dart To execute through WebStorm IDE

  • Right-click the script file on the IDE ( it should contain main() function )

  • Click on the Run <file_name option>.