Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Constants: "final static" vs. "final"

807600Jul 19 2007 — edited Jul 20 2007
In a GUI object, I have some class constants that are only used internally. Example 1:
private final int PREFERRED_WIDTH = MainWin.MAX_WINDOW_WIDTH;
private final int PREFERRED_HEIGHT = 50;
Example 2:
private final JButton helpButton = new JButton("Help");
private final JButton closeButton = new JButton("Close");
private final JLabel clearanceLabel = createClearanceLabel();
Should the members in EX1, EX2 be static??
These items are members of a GUI object, and there is only 1 instance of this GUI object during application runtime.


The nature of my question is about the best practices of when to use the "static" modifier for private class constants.

Thank you

Message was edited by:
PatrickFinnigan
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 17 2007
Added on Jul 19 2007
14 comments
677 views