Advertisement

第一个 Dart 程序

阅读量:

使用Android Studio运行Dart程序

创建lib/demos/c01_hello.dart, 填写:

复制代码
    void main(){
      print("hello world!");
    }

右键运行即可.

两个数相加

As a demonstration, should we write another straightforward program adding two numbers?

在这个例子中,让我们再写一个简单的程序来将两个数字相加:

复制代码
    void main() {
      int num1 = 10;
      int num2 = 20;
      int sum = num1 + num2;
      print(“The sum of $num1 and $num2 is $sum”);
    }

In this case, we define two integer variables named num1 and num2 and set their values to 10 and 20 respectively. After computing their sum, we save it into a variable called sum.

全部评论 (0)

还没有任何评论哟~