Hi, A default access modifier is not public, but why for an interface method, a default modifier (i.e. no modifier) makes the method public? It should'nt right? default is default If that's allowed, then why is'nt the interface itself allowed that implicity? [ May 02, 2006: Message edited by: Allen Sylvester ]
Life is like a day. If the day is of no use, neither a month or a year.
wise owen
Ranch Hand
Joined: Feb 02, 2006
Posts: 2023
posted
0
All interfaces are implicitly abstract and inclusion of that modifier is optional.
Dick Eimers
Ranch Hand
Joined: Apr 15, 2006
Posts: 40
posted
0
You should note the difference between default and implicit.
You can prefix any combination of public and abstract modifiers to method declarations in an interface and it still would be the same as not having a modifier...got it?
Eg: interface Dummy { void doDummy(); }
interface Dummy { public void doDummy(); }
interface Dummy { abstrtact void doDummy(); }
interface Dummy { public abstract void doDummy(); } are all the same.
SCJP 5.0 | SCWCD 1.4 <br /> <br />If you don't know where you are going, any road will take you there!
Kristian Perkins
Ranch Hand
Joined: Mar 27, 2006
Posts: 32
posted
0
public is the only access modifier allowed for interface methods, so a default access modifier of anything other that public would not make sense.
I'm talking in a purist's way, I guess. A default access modifier allows access , only in the same package. why is'nt that rule followed in an interface. I know that an interface can have only public methods, then why is it not Mandatory to put a 'public' access modifier? well, this is just purist probably. okay anyway, thanks anyway
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.