<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # Kotlin 表達式,語句和塊 > 原文: [https://www.programiz.com/kotlin-programming/statement-expression](https://www.programiz.com/kotlin-programming/statement-expression) #### 在本文中,您將了解 Kotlin 表達式,Kotlin 語句,表達式與語句之間的差異以及 Kotlin 塊。 ## Kotlin 表達式 表達式由計算為單個值的[變量](/kotlin-programming/variable-types "Kotlin Variables"),[運算符](/kotlin-programming/operators "Kotlin Operators")等組成。 讓我們舉個例子 ```kt val score: Int score = 90 + 25 ``` 在此,`90 + 25`是返回`Int`值的表達式。 * * * 在 Kotlin 中,`if`是不同于 Java 的表達式(在 Java 中,`if`是一條語句)。 例如, ```kt fun main(args: Array<String>) { val a = 12 val b = 13 val max: Int max = if (a > b) a else b println("$max") } ``` 在此,`if (a > b) a else b`是一個表達式。 然后在上述程序中將表達式的值分配給`max`變量。 訪問此頁面以了解有關表達式的更多信息。 * * * ## Kotlin 語句 語句是構成完整執行單元的所有內容。 例如, ```kt val score = 90 + 25 ``` 在此,`90 + 25`是返回 115 的表達式,`val score = 9*5;`是語句。 表達式是語句的一部分。 一些例子: ```kt println("Howdy") ``` ```kt var a = 5 ++a ``` ```kt max = if (a > b) a else b ``` * * * ## Kotlin 塊 塊是用大括號`{ }`括起來的一組語句(零個或多個)。 例如, ```kt fun main(args: Array<String>) { // main function block val flag = true if (flag == true) { // start of if block print("Hey ") print("jude!") } // end of if block } // end of main function block ``` `if`分支塊中有兩個語句`print("Hey ")`和`print(" jude!")`。 ```kt print("Hey ") print("jude!") ``` 同樣,`main()`函數也具有塊體。 ```kt val flag = true if (flag == true) { // start of block print("Hey ") print("jude!") } // end of block ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看