Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
paul wheaton
Ron McLeod
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
Programmer Certification (OCPJP)
interface problem
adam Lui
Ranch Hand
Posts: 186
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
"you can declare variables inside an interface, but you cant change their values in a class that implements the interface."
I dont really get it...
Can anyone show me an example demonstrates the point?
ahmed yehia
Ranch Hand
Posts: 424
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Because interface variables are by default
public static
final
, you cant change their values.
Keith Flo
Ranch Hand
Posts: 128
I like...
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
This is true even if 'public static final' is not included in the variable declaration. (see K&B p. 22)
For example:
interface Foo {
int BAR = 42;
void go();
}
In this example BAR is a constant and is 'public static final' by default.
kf
SCJP 5.0 (preparing for SCWCD)
chander shivdasani
Ranch Hand
Posts: 206
I like...
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
consider an interface
interface if {
int i = 20;
}
in this case i by default is public static final .So you cant change the value of i in any class that implements the interface.
Enjoy, Chander
SCJP 5, Oracle Certified PL/SQL Developer
Why does your bag say "bombs"? The reason I ask is that my bag says "tiny ads" and it has stuff like this:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
B&S 2.1.2 Interface
Why Spring framework use cglib and asm
Servlet-Servlet Communication
Inner Classes in Interfaces?
Why does this code thorow exception?
More...