Jump to content
xisto Community
Sign in to follow this  
magiccode91405241511

Override Or Shadow Interface Constant Variable

Recommended Posts

I have played around java object and interface to see how they work together.
I think it is not that hard to understand, but, I came with a question now.

What the java tutorial said (downloaded from Sun web site)
an interface constant literal variable are implicity declared as

public, static, final

It is fine and correct when an interface implmented by a class and tried assign a value to it and reported an error.

But what confused me is I can declare a variable named the same as the interface do in a class that implemented it, and it don't produce any errors.
If I'am not wrong, c# would rasie an error.

public interface IInterace(){	int state = 0; /* implicity public state final */}public class AClass implements IInterface{   int state = 1; /* is this override or shadowed ? */}

Any ideas would be appreciated .

Thanks,

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.