<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>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # Java 注釋 > 原文: [https://www.programiz.com/java-programming/comments](https://www.programiz.com/java-programming/comments) #### 在本教程中,您將了解 Java 注釋,為什么使用它們以及如何以正確的方式使用注釋。 在計算機編程中,注釋是程序的一部分,Java 編譯器完全忽略了注釋。 它們主要用于幫助程序員理解代碼。 例如, ```java // declare and initialize two variables int a =1; int b = 3; // print the output System.out.println("This is output"); ``` 在這里,我們使用了以下注釋: * 聲明并初始化兩個變量 * 打印輸出 * * * ## Java 中的注釋類型 在 Java 中,有兩種類型的注釋: * 單行注釋 * 多行注釋 * * * ### 單行注釋 單行注釋在同一行中開始和結束。 要編寫單行注釋,我們可以使用`//`符號。 例如, ```java // "Hello, World!" program example class Main { public static void main(String[] args) { { // prints "Hello, World!" System.out.println("Hello, World!"); } } ``` **輸出**: ```java Hello, World! ``` 在這里,我們使用了兩個單行注釋: * `"Hello, World!" program example` * `prints "Hello, World!"` Java 編譯器忽略從`//`到行尾的所有內容。 因此,它也被稱為**行尾**注釋。 * * * ### 多行注釋 當我們想寫多行注釋時,可以使用多行注釋。 要寫多行注釋,我們可以使用`/*....*/`符號。 例如, ```java /* This is an example of multi-line comment. * The program prints "Hello, World!" to the standard output. */ class HelloWorld { public static void main(String[] args) { { System.out.println("Hello, World!"); } } ``` **輸出**: ```java Hello, World! ``` 在這里,我們使用了多行注釋: ```java /* This is an example of multi-line comment. * The program prints "Hello, World!" to the standard output. */ ``` 這種類型的注釋也稱為**傳統注釋**。 在這種類型的注釋中,Java 編譯器會忽略從`/*`到`*/`的所有內容。 * * * ## 正確使用注釋 您應該始終考慮一件事,即注釋不應該替代解釋英文書寫不好的代碼的方法。 您應該始終編寫結構合理且自我解釋的代碼。 然后,使用注釋。 有些人認為代碼應該是自描述的,注釋應該很少使用。 但是,以我個人的觀點,使用注釋沒有錯。 我們可以使用注釋來解釋復雜的算法,正則表達式或需要在不同技術中選擇一種技術來解決問題的方案。 **注意**:在大多數情況下,請始終使用注釋來解釋“**為什么做**”,而不是“**怎樣做**”,您很高興。
                  <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>

                              哎呀哎呀视频在线观看