A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
variavle declaration in interface
Joined: Dec 14, 2006
Jan 04, 2007 06:06:00
Is it mandatory to intialize a variable declared in an interface?
Joined: Aug 21, 2004
Jan 04, 2007 07:28:00
Yes! I think they are.
Try comiling a interface with a variable that is not instanciated and you will get a compile error
Joined: Oct 30, 2001
Jan 04, 2007 08:52:00
You can't declare variables in interfaces. You can only have public static final fields - i.e. constants. These must be given a value within the interface.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Jeroen T Wenting
Joined: Apr 21, 2006
Jan 04, 2007 10:15:00
And you shouldn't do that... Effective Java, topic 17.
I agree. Here's the link:
subject: variavle declaration in interface
Home interface or Home Interface stub
How To Call Two Different Classes From the Main Program Using the Same API?
Writing an Interface
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013