File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes In interface if any variable is declared then no need to initialize. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "In interface if any variable is declared then no need to initialize. " Watch "In interface if any variable is declared then no need to initialize. " New topic
Author

In interface if any variable is declared then no need to initialize.

jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576
In Java class If any variable is declared then no need to initialize the variable. But In interface if any variable is declared then no need to initialize.
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
jacob deiter wrote:In Java class If any variable is declared then no need to initialize the variable. But In interface if any variable is declared then no need to initialize.


per the JLS, every "variable" declared in an interface is implicitly public, static, and final.
per the JLS, 9.3.1: Every field in the body of an interface must have an initialization expression, which need not be a constant expression. The variable initializer is evaluated and the assignment performed exactly once, when the interface is initialized.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: In interface if any variable is declared then no need to initialize.
 
Similar Threads
Local variables
variavle declaration in interface
Static Int and Methods
Static method local variables
Doubt with static initializers