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!

Enum Question

843785Mar 15 2009 — edited Mar 15 2009
I have a question about enums. How should I implement a default constructor that involves the enum listed below. Should I declare a value of ZERO or NOTHING in the enum set just for use in the default constructor? Or is the null type ok to use, like I have it below? Is there an appropriate way to specify enum types in the constructor? This might be a dumb question but do I need to even worry about the enum in the default constructor (we are required to specify a default constructor). I am sorry in advance for poor coding techniques. Any help would be appreciated. I did check out http://java.sun.com/j2se/1.5.0/docs/guide/language/enums.html, for help on enums, but it does not seem to answer my question about default constructors. Thanks for your help in advance.
 
public enum Rating {TV_G, TV_7, TV_14, TV_MA} 
    public Rating ApprRating; 
    public String ProgramTitle; 
    public Duration Length; 
    public String Description; 

    public TVProgram(){ 
        ProgramTitle = "No Title yet!"; 
        Length = null; 
        ApprRating = null; 
        Description = "No Description yet!"; 
    } 
     
    public TVProgram(String ProTitle, Duration Len, Rating Rat, String Disc){ 
        ProgramTitle = ProTitle; 
        Length = Len; 
        ApprRating = Rat; 
        Description = Disc; 
    } 
     
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 12 2009
Added on Mar 15 2009
4 comments
165 views