It is worth taking a look at the excellent book 'Effective Java' by Joshua
Bloch - he outlines a number of reasons for avoiding the constant interface
pattern and instead advocates the use of a constant utility class as in..

public class MyInterface {
    public static final String YES = "yes";
}

db


-----Original Message-----
From: Carl Smith [mailto:[EMAIL PROTECTED]
Sent: 22 January 2005 15:50
To: user@struts.apache.org
Subject: constants interface


In Java, sometimes you would define an interface containg the constants:

public interface MyInterface {
    public static final String YES = "yes";
}

To access the contants, there are two ways

public class WayOne {
    public void myMethod(){
           String yes = MyInterface.YES;
           //...
    }
}

public class WayTwo implements MyInterface {
    public void myMethod(){
           String yes = YES;
           //...
    }
}

I am asking which one is better? Or they are Ok and depend on the developer
's flavor?



signature

---------------------------------
Do you Yahoo!?
 Yahoo! Search presents - Jib Jab's 'Second Term'
======================================================= 
This message has been scanned for viruses and dangerous 
content using Vet Anti-Virus Protection and is believed 
to be clean. 
=======================================================

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to