aspose file tools
The moose likes Beginning Java and the fly likes variavle declaration in interface Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "variavle declaration in interface" Watch "variavle declaration in interface" New topic
Author

variavle declaration in interface

vijay kumarg
Ranch Hand

Joined: Dec 14, 2006
Posts: 105
Is it mandatory to intialize a variable declared in an interface?
Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367
Yes! I think they are.

Try comiling a interface with a variable that is not instanciated and you will get a compile error
= expected


SCJP1.4
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
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.<br /> <br />#:^P
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
And you shouldn't do that... Effective Java, topic 17.


42
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: variavle declaration in interface
 
Similar Threads
How To Call Two Different Classes From the Main Program Using the Same API?
Regarding Interfaces
Writing an Interface
Time Capsule
Home interface or Home Interface stub