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
Ron McLeod
Paul Clapham
Tim Cooke
Devaka Cooray
Sheriffs:
Liutauras Vilda
paul wheaton
Rob Spoor
Saloon Keepers:
Tim Moores
Stephan van Hulst
Tim Holloway
Piet Souris
Mikalai Zaikin
Bartenders:
Carey Brown
Roland Mueller
Forum:
Programmer Certification (OCPJP)
interface problem
adam Lui
Ranch Hand
Posts: 186
posted 16 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 16 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 16 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 16 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
Stop it! You're embarassing me! And you are embarrassing this tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
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...