Interface Contents

Here again are the elements that can go into an interface:

  • public, static, final data members. This is about the closest you get in Java to a global constant. By default, even if you don't declare them as such, all the data members of an interface are public, static, and final. So you could code

       int MAIN_BRANCH_NUMBER = 01;
    

    or you could code

       public static final int MAIN_BRANCH_NUMBER = 01;
    

    The Java Language Specification says that it is strongly discouraged to redundantly specify these keywords. I happen to disagree and feel strongly that, for the sake of those who don't know the rules, you should specify the keywords. Doing so is useful for documentation purposes and certainly doesn't hurt anything. What's more, the keywords ...

Get PURE Java™ 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.