What is the best practice to declare a java file having only constant?
public interface DeclareConstants
{
String constant = "Test";
}
OR
public abstract class DeclareConstants
{
public static final String constant = "Test";
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Neither one. Use
final class for Constantsdeclare them aspublic static finaland static import all constants wherever necessary.Usage :
See wiki link : http://en.wikipedia.org/wiki/Constant_interface