Hi, I have a interface which only has constants declared in it. Now to access these constants from a class I can have two ways 1) As the constants are public and static I can access them directly in my class as InterfaceName.ConstantVar 2) I can make the class implememt the interface and then I can directly access the constants of the interface in my class as if they were declared in the class itself. ConstantVar Which is better? Thanks & Regards, Deepak
There is no point in implementing such an interface. The good way to access static fields is to use the ClassName.FieldName format so that some one looking at your code will know that this field is static.
Please keep to SCJP topics in this forum. We have other Java forums for discussing these more general issues. Moving to Java In General (Intermediate).