Interface variables.

Hi All. I have a performance related question regarding interface variables. Consider the following interface... interface I { // First case int i=0; } Since all variables declared in an interface are implicitly 'public static final', is it better to specify this explicitly as in the following? interface I { // Second case public static final int i=0; } My hunch is that there would be no problem or overheads with the Second case since final variables are compile time constants & do not have any effect during Runtime. Pls. give your comments on above. thanks - Himanshu

Originally posted by Himanshu Jhamb: Since all variables declared in an interface are implicitly 'public static final'...

Based upon the fact that any member variables in an interface are implicitly static and final, I would assume that writing your code in either way would result in the same bytecodes being produced. Indeed, I just compiled the following code:

Hi Himanshu, Performance-wise, it probably makes no difference at all. But explicitly declaring interface variables as public static final is better coding style since even novices (who might not know this implicit rule) can see your intent.

Hope this helps Michael Morris SCJP2

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher

I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com