久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<tfoot id='JCDxn'></tfoot>

      <i id='JCDxn'><tr id='JCDxn'><dt id='JCDxn'><q id='JCDxn'><span id='JCDxn'><b id='JCDxn'><form id='JCDxn'><ins id='JCDxn'></ins><ul id='JCDxn'></ul><sub id='JCDxn'></sub></form><legend id='JCDxn'></legend><bdo id='JCDxn'><pre id='JCDxn'><center id='JCDxn'></center></pre></bdo></b><th id='JCDxn'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='JCDxn'><tfoot id='JCDxn'></tfoot><dl id='JCDxn'><fieldset id='JCDxn'></fieldset></dl></div>
    1. <small id='JCDxn'></small><noframes id='JCDxn'>

    2. <legend id='JCDxn'><style id='JCDxn'><dir id='JCDxn'><q id='JCDxn'></q></dir></style></legend>
      • <bdo id='JCDxn'></bdo><ul id='JCDxn'></ul>

        Java 中的@interface 默認聲明用法

        @interface default declaration usage in Java(Java 中的@interface 默認聲明用法)
          <legend id='r2CbI'><style id='r2CbI'><dir id='r2CbI'><q id='r2CbI'></q></dir></style></legend>

            <bdo id='r2CbI'></bdo><ul id='r2CbI'></ul>
            <i id='r2CbI'><tr id='r2CbI'><dt id='r2CbI'><q id='r2CbI'><span id='r2CbI'><b id='r2CbI'><form id='r2CbI'><ins id='r2CbI'></ins><ul id='r2CbI'></ul><sub id='r2CbI'></sub></form><legend id='r2CbI'></legend><bdo id='r2CbI'><pre id='r2CbI'><center id='r2CbI'></center></pre></bdo></b><th id='r2CbI'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='r2CbI'><tfoot id='r2CbI'></tfoot><dl id='r2CbI'><fieldset id='r2CbI'></fieldset></dl></div>

              <small id='r2CbI'></small><noframes id='r2CbI'>

            • <tfoot id='r2CbI'></tfoot>

                <tbody id='r2CbI'></tbody>

                  本文介紹了Java 中的@interface 默認聲明用法的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我剛剛發現了這個功能.

                  I have just discovered this feature.

                  使用@interface"語法聲明接口允許您放置默認值.

                  Declaring an interface using the "@interface" syntax allows you to put a default value.

                  public @interface HelloWorld { 
                       public String sayHello() default "hello world";
                  }
                  

                  這對我來說是新事物.假設如何使用該默認值.

                  This is something new for me. How is that default value suppose to be used.

                  我找不到對此的引用,因為在 Java 1.5 中添加@"之前,www 中充滿了 java 接口文檔(是在 .5 還是在 .4?)

                  I cannot find references to that, because the www is full of java interface documents prior to "@" addition in Java 1.5 ( was it on .5 or in .4? )

                  編輯

                  感謝您的回答(我有點接近注釋",因為我已經使用了標簽):P

                  幾年前我就知道我應該閱讀該文件!!!...讓我們看看...

                  I knew I should've read that document years ago!!!... let's see...

                  許多 API 需要相當多的樣板代碼.對于....

                  推薦答案

                  你剛剛寫了一個注解.

                  特別關于 default 語句:這是因為注解和接口不能有構造函數,所以這是為注解屬性設置默認值的唯一方法.來自 Java 語言規范:

                  Regarding the default statement in particular: This is used because annotations and interfaces can't have constructors, so this is the only way to have a default value for an annotation attribute. From the Java Language Specification:

                  注解類型元素可以有一個為其指定的默認值.這是通過在其(空)參數列表后面加上關鍵字 default 和元素的默認值來完成的.

                  An annotation type element may have a default value specified for it. This is done by following its (empty) parameter list with the keyword default and the default value of the element.

                  在讀取注釋時動態應用默認值;默認值不會編譯到注釋中.因此,更改默認值會影響注釋,即使在更改之前編譯的類中也是如此(假設這些注釋缺少默認元素的顯式值).

                  Defaults are applied dynamically at the time annotations are read; default values are not compiled into annotations. Thus, changing a default value affects annotations even in classes that were compiled before the change was made (presuming these annotations lack an explicit value for the defaulted element).

                  我注意到 java.lang.annotation 不過使用默認值.

                  I note that none of the annotations in java.lang.annotation use default values, though.

                  用法:你有一個注解@HelloWorld和一個屬性sayHello.你可以把它放在這樣的類上:

                  Usage: You have an annotation @HelloWorld with an attribute sayHello. You could put it on a class like this:

                  @HelloWorld(sayHello="Hi")
                  public class MyClass {
                  }
                  

                  因為你有一個默認值,你可以放

                  Since you have a default value, you could just put

                  @HelloWorld
                  public class MyClass {
                  }
                  

                  (請注意,文檔中說,在帶有單個元素的注釋中,該元素應命名為 value";我認為這樣做的唯一原因是您可以只寫 @HelloWorld("Hi") 無需命名參數.)

                  (Note that the document says, "In annotations with a single element, the element should be named value"; I believe the only reason to do this is that you could just write @HelloWorld("Hi") without having to name the parameter.)

                  正如所寫,您的注釋可用于任何有效的程序元素(包括方法和變量聲明).您可以使用 @Target 更改它 注釋.

                  As written, your annotation can be used on any valid program element (including methods and variable declarations). You can change this with the @Target annotation.

                  最后,設置 RetentionPolicy 讓您決定注解是應該被編譯器丟棄、被 VM 丟棄還是一直保留.

                  Finally, setting the RetentionPolicy lets you decide if the annotation should be discarded by the compiler, discarded by the VM, or kept always.

                  兩個可能也很有趣的包:javax.annotation 和 javax.annotation.processing.和 這里是使用注釋處理進行源代碼分析的示例.

                  Two packages that might also be interesting: javax.annotation and javax.annotation.processing. And here is an example of using annotation processing for source code analysis.

                  這篇關于Java 中的@interface 默認聲明用法的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  quot;Char cannot be dereferencedquot; error(“Char 不能被取消引用錯誤)
                  Java Switch Statement - Is quot;orquot;/quot;andquot; possible?(Java Switch 語句 - 是“或/“和可能的?)
                  Java Replace Character At Specific Position Of String?(Java替換字符串特定位置的字符?)
                  What is the type of a ternary expression with int and char operands?(具有 int 和 char 操作數的三元表達式的類型是什么?)
                  Read a text file and store every single character occurrence(讀取文本文件并存儲出現的每個字符)
                  Why do I need to explicitly cast char primitives on byte and short?(為什么我需要在 byte 和 short 上顯式轉換 char 原語?)
                    <bdo id='gDFHY'></bdo><ul id='gDFHY'></ul>

                          <small id='gDFHY'></small><noframes id='gDFHY'>

                            <tbody id='gDFHY'></tbody>

                            <legend id='gDFHY'><style id='gDFHY'><dir id='gDFHY'><q id='gDFHY'></q></dir></style></legend><tfoot id='gDFHY'></tfoot>
                          1. <i id='gDFHY'><tr id='gDFHY'><dt id='gDFHY'><q id='gDFHY'><span id='gDFHY'><b id='gDFHY'><form id='gDFHY'><ins id='gDFHY'></ins><ul id='gDFHY'></ul><sub id='gDFHY'></sub></form><legend id='gDFHY'></legend><bdo id='gDFHY'><pre id='gDFHY'><center id='gDFHY'></center></pre></bdo></b><th id='gDFHY'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='gDFHY'><tfoot id='gDFHY'></tfoot><dl id='gDFHY'><fieldset id='gDFHY'></fieldset></dl></div>

                            主站蜘蛛池模板: av国产精品 | 欧美 日韩 国产 在线 | 久久国产婷婷国产香蕉 | 成人久久久 | 美女亚洲一区 | 久久99精品久久久久久噜噜 | 国产精品久久久久久久久久妇女 | 欧美激情综合色综合啪啪五月 | 精品欧美一区二区三区免费观看 | 国产九九九 | 亚洲一区免费视频 | 黄色一级片在线播放 | 国产成在线观看免费视频 | 欧美激情第一区 | 亚洲精彩视频在线观看 | 免费成人高清在线视频 | 91在线免费视频 | 欧美色图综合网 | 国产精久久久久久久 | 欧美一区免费 | 亚洲欧美综合精品久久成人 | 91久久精品一区二区三区 | 午夜精品久久久久久 | 国产精品成人一区二区三区 | 精品美女视频在免费观看 | 中文字幕av网站 | 欧美a区 | 国产精品久久久久久久久久久久久 | 天天搞天天搞 | 精品国产一级 | 最新毛片网站 | 99精品久久 | 伊人精品在线视频 | 欧美二区在线 | 91精品在线看 | 欧美无乱码久久久免费午夜一区 | 欧美激情一区 | 日韩视频在线一区 | japanhdxxxx裸体 | 久久亚洲一区二区三区四区 | 狠狠婷婷综合久久久久久妖精 |