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

<tfoot id='7eHJE'></tfoot>
  • <small id='7eHJE'></small><noframes id='7eHJE'>

  • <legend id='7eHJE'><style id='7eHJE'><dir id='7eHJE'><q id='7eHJE'></q></dir></style></legend>

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

        如何從常量 java 為注解提供值

        How to supply value to an annotation from a Constant java(如何從常量 java 為注解提供值)
        <tfoot id='8rpNi'></tfoot>
        1. <small id='8rpNi'></small><noframes id='8rpNi'>

              <tbody id='8rpNi'></tbody>
            • <legend id='8rpNi'><style id='8rpNi'><dir id='8rpNi'><q id='8rpNi'></q></dir></style></legend>
                <bdo id='8rpNi'></bdo><ul id='8rpNi'></ul>

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

                  本文介紹了如何從常量 java 為注解提供值的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我認為這在 Java 中可能是不可能的,因為注解及其參數是在編譯時解析的.我有一個界面如下,

                  I am thinking this may not be possible in Java because annotation and its parameters are resolved at compile time. I have an interface as follows,

                  public interface FieldValues {
                     String[] FIELD1 = new String[]{"value1", "value2"};
                  }
                  

                  和另一個類,

                  @SomeAnnotation(locations = {"value1", "value2"})
                  public class MyClass {
                     ....
                  }
                  

                  我用注釋標記了許多類,我想知道是否可以避免在我更喜歡使用的每個注釋中指定字符串

                  I mark many classes with the annotation and I would like to know if I can avoid specifying the strings in every annotation I would instead prefer to use

                  @SomeAnnotation(locations = FieldValues.FIELD1)
                  public class MyClass {
                     ....
                  }
                  

                  但是這會產生編譯錯誤,例如注釋值應該是數組初始化器等.有人知道我如何使用 String 常量或 String[] 常量來為注釋提供值嗎?

                  However this gives compilation errors like annotation value should be an array initializer etc. Does someone know how I can use a String constant or String[] constant to supply value to an annotation?

                  推薦答案

                  編譯常量只能是原語和字符串:

                  15.28.常量表達式

                  編譯時常量表達式是一個表達式,表示原始類型的值或不會突然完成且僅使用以下內容組成的字符串:

                  A compile-time constant expression is an expression denoting a value of primitive type or a String that does not complete abruptly and is composed using only the following:

                  • 原始類型的文字和 String
                  • 類型的文字
                  • 轉換為原始類型并轉換為 String
                  • [...] 運算符 [...]
                  • 帶括號的表達式,其包含的表達式是常量表達式.
                  • 引用常量變量的簡單名稱.
                  • TypeName 形式的限定名稱.標識符表示常量變量.
                  • Literals of primitive type and literals of type String
                  • Casts to primitive types and casts to type String
                  • [...] operators [...]
                  • Parenthesized expressions whose contained expression is a constant expression.
                  • Simple names that refer to constant variables.
                  • Qualified names of the form TypeName . Identifier that refer to constant variables.

                  實際上在java中沒有辦法保護數組中的項目.在運行時,總是有人可以執行 FieldValues.FIELD1[0]=value3",因此如果我們更深入地觀察,數組不可能是真正的常量.

                  Actually in java there is no way to protect items in an array. At runtime someone can always do FieldValues.FIELD1[0]="value3", therefore the array cannot be really constant if we look deeper.

                  這篇關于如何從常量 java 為注解提供值的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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='mRl3n'></bdo><ul id='mRl3n'></ul>
                        <tbody id='mRl3n'></tbody>

                    • <legend id='mRl3n'><style id='mRl3n'><dir id='mRl3n'><q id='mRl3n'></q></dir></style></legend>

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

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

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

                            主站蜘蛛池模板: 精品一区二区三区在线视频 | 国产黄视频在线播放 | 男人天堂网站 | 人人干人人艹 | 中文字幕 国产 | 亚洲一二三区精品 | 中文字幕亚洲欧美日韩在线不卡 | 日韩中文字幕在线视频观看 | 亚洲成人三级 | 久久精品亚洲 | 91在线看片| 日韩精品一区二区三区视频播放 | 久久成人免费观看 | 中文字幕在线二区 | 999久久久国产精品 欧美成人h版在线观看 | 草久久久| 在线播放一区二区三区 | 日韩高清中文字幕 | 日韩视频在线一区 | 性色av网站 | 国产欧美一级二级三级在线视频 | 亚洲欧美日韩精品久久亚洲区 | 亚洲国产精品久久久 | 国产精品成人在线 | 国产一区二区精品在线观看 | 91精品久久久久久久久中文字幕 | 欧美性久久久 | 黑人一级片视频 | 国产91视频一区二区 | 国产日韩欧美在线 | 国产真实精品久久二三区 | aaa综合国产 | 日韩综合| 国产精品成人一区二区 | 欧美一级大片免费看 | 欧美日韩中文国产一区发布 | 成人亚洲精品久久久久软件 | 高清亚洲| 久久亚洲国产精品日日av夜夜 | 一级黄色裸片 | 男女性毛片 |