Interface question

Discussion in 'Java' started by Sparko, Mar 2, 2004.

  1. Sparko

    Sparko Guest

    If one defines an interface with no method declarations, just public
    static final constants, can one then refer to the constants in the
    implementing class or are the constants defined in the interface only
    available in an implemented method.
    Sparko, Mar 2, 2004
    #1
    1. Advertising

  2. Sparko

    Johann Weber Guest

    Sparko wrote:
    > If one defines an interface with no method declarations, just public
    > static final constants, can one then refer to the constants in the
    > implementing class or are the constants defined in the interface only
    > available in an implemented method.


    Writing this question (I'm not shure I understand it fully) takes more
    time than writing the code to try it out.

    Just try it out!
    Johann Weber, Mar 2, 2004
    #2
    1. Advertising

  3. Sparko

    xarax Guest

    "Sparko" <> wrote in message
    news:...
    > If one defines an interface with no method declarations, just public
    > static final constants, can one then refer to the constants in the
    > implementing class or are the constants defined in the interface only
    > available in an implemented method.


    A class that implements an interface will inherit
    all of the declarations and fields of that interface.
    xarax, Mar 2, 2004
    #3
  4. "xarax" <> writes:

    > A class that implements an interface will inherit
    > all of the declarations and fields of that interface.


    Sometimes called the "pre-1.5-static-import-hack". :)
    Tor Iver Wilhelmsen, Mar 2, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wildepiet
    Replies:
    0
    Views:
    1,860
    Wildepiet
    Jun 14, 2004
  2. cyberco
    Replies:
    8
    Views:
    487
    cyberco
    Feb 25, 2006
  3. Xah Lee
    Replies:
    15
    Views:
    583
    Sherm Pendley
    Mar 23, 2007
  4. Xah Lee
    Replies:
    15
    Views:
    629
    Sherm Pendley
    Mar 23, 2007
  5. Replies:
    4
    Views:
    344
    timjowers
    Nov 2, 2007
Loading...

Share This Page