| Author |
having protected variables in interfaces?
|
Justin Fox
Ranch Hand
Joined: Jan 24, 2006
Posts: 802
|
|
ok, i was wondering can you have protected variables that you can modify in your classes? umm, somethin like
|
You down with OOP? Yeah you know me!
|
 |
Alana Sparx
Ranch Hand
Joined: Feb 14, 2006
Posts: 121
|
|
I'm fairly sure interfaces only allow you to have public, static and/or final modifiers for methods and primitives. The compiler should tell you though.....
|
 |
Peter Chase
Ranch Hand
Joined: Oct 30, 2001
Posts: 1970
|
|
You can't have any fields/variables in an interface, except constants (public static final). You can't have any access modifiers, except public. Generally, you should not bother writing the "public" in interfaces, as everything is public anyway. Well, perhaps this is a matter of style, but I think so.
|
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.<br /> <br />#:^P
|
 |
Vinayak patil
Ranch Hand
Joined: Aug 30, 2005
Posts: 67
|
|
I have a question related to variables in interfaces: Why do we have to initialize the variables when we declare them in an interface? And why are they treated as final variables? Thanks in advance, Vinayak
|
"I can resist everything except temptation"
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24050
|
|
|
Because they are not "variables" -- that's the whole point. They're constants. Interfaces can't include any per-instance data.
|
[Jess in Action][AskingGoodQuestions]
|
 |
 |
|
|
subject: having protected variables in interfaces?
|
|
|