Friday, July 29, 2011

Compile-time constants in Java annotation element values

In hindsight, this should've been obvious:
public class CompileTimeConstantsTest {
    @interface Awesome { String value(); }
    private static final String X = "X";
    private final int a = 1;
    public final int b = 1;

    @Awesome(a < b ? X : X + X) // compiles just fine
    int whatever;


  1. I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly.

    Php course in chennai

  2. wow great Article, the details you have provided are much clear, easy to understand, if you post some more Article, it will be very much useful for me.
    PHP Training in Chennai

  3. thanks for your details its very useful nice article I got more information web design company in velachery

  4. Wow i can say that this is another great article as expected of this blog.Bookmarked this site.. Kopar at Newton at Newton MRT Station