Extending Java Enums

Posted by CaseyB on Stack Overflow See other posts from Stack Overflow or by CaseyB
Published on 2010-04-15T01:57:39Z Indexed on 2010/04/15 2:03 UTC
Read the original article Hit count: 313

Filed under:
|

Here's what I am looking to accomplish, I have a class that has an enum of some values and I want to subclass that and add more values to the enum. This is a bad example, but:

public class Digits
{
 public enum Digit
 {
  0, 1, 2, 3, 4, 5, 6, 7, 8, 9
 }
}

public class HexDigits extends Digits
{
 public enum Digit
 {
  A, B, C, D, E, F
 }
}

so that HexDigits.Digit contains all Hex Digits. Is that possible?

© Stack Overflow or respective owner

Related posts about java

Related posts about enums