Interface question

S

Sparko

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.
 
J

Johann Weber

Sparko said:
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!
 
X

xarax

Sparko said:
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.
 
T

Tor Iver Wilhelmsen

xarax said:
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". :)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top