KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Right now I'm thinking about adding a private constructor to a class that only holds some String constants. public class MyStrings { // I want to add this: private MyString() {} public static final String ONE = "something"; public static final String TWO = "another"; ... } Is there any performance or memory overhead if I add a private constructor to this class to prevent someone to instantiate it? Do you think it's necessary at all or that private constructors for this purpose are a waste of time and code clutter? UPDATE I'm going for a final class with private constructor and a descriptive javadoc for the class. I can't use a ENUM (which I'd prefer) because I'm stuck on Java 1.4 for now. This would be my modification: /** * Only for static access, do not instantiate this class. */ public final class MyStrings { private MyString() {} public static final String ONE = "something"; public static final String TWO = "another"; ... }
Tags (comma-separated)
Save Edits
Cancel