Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • Have you looked at the wiki on this topic? I think it explains it pretty well. en.wikipedia.org/wiki/Constant_folding Commented Jan 15, 2011 at 18:04
  • You can use a method instead of exposing this field (probably best), use final but pass the value through a method ("1.6".toString()) or add some code to prevent it being a compile-time constant yet not add any unnecessary bytecode (null!=null?"": "1.6"). Commented Jan 15, 2011 at 18:11
  • Yeah, public static constants are icky! Commented Jan 15, 2011 at 18:22
  • @CoolBeans, I have checked the wiki. The example in wiki is explaining what the constant folding is. I just confused at this point. Thanks for everyone explanation. It seems a best practice for library release. :) Commented Jan 15, 2011 at 21:19
  • The code is bad and I'd bet it dates for years. It should have been a method call or something like that: public static String REQUESTED_API_VERSION = new String("1."+"6"); //new String is not literal, so it'll result in GETSTATIC Commented Jan 28, 2011 at 11:54