Can I can create public static final variables in an interface? Can I keep some common constant values defined in these files?
Can I can create public static final variables in an interface? Can I keep
Share
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.
Yes, you can:
However, it’s generally reckoned not to be a good idea these days. It’s not so bad if the interface has a real purpose as well, and the constants are likely to be used by most of the implementations… but introducing an interface just to make it easier to get to constants is an abuse of the purpose of interfaces, really. (And that’s what used to happen a lot.)