3

Can Any one expalin me whats the use of this interface

TestEnum<E extends Enum<E> & TestEnum<E, V>, V>{....}

enum test implements TestEnum<test, Integer>{....}

I am rookie on the enumeration can any one say what that "&" means

RaM PrabU
  • 415
  • 4
  • 16
  • 3
    Yes, the `&` just means that `E` must extend both of those types. – Dawood ibn Kareem Feb 08 '18 at 07:30
  • 3
    This means that E have to be an enum and an implementation of EnhancedEnum of E (the enum) and V. V can be whatever in this case. – Nyranith Feb 08 '18 at 07:34
  • can you explain me what the are tyring to achieve by looking at that code – RaM PrabU Feb 08 '18 at 07:34
  • that's going to hard to explain, it depends on where you got this code - may be for a certain application this makes perfect sense... – Eugene Feb 08 '18 at 09:04
  • 1
    The code you have posted does not compiled, as `test` does not implement `EnhancedEnum`, so it’s not valid as first type argument for `TestEnum`. Well, I guess `TestEnum` and `EnhancedEnum` are supposed to be the same, but how are we supposed to tell you what the code ought to achieve from only two lines of it, which are not even copied correctly? – Holger Feb 08 '18 at 10:59
  • 2
    The `&` is a *type intersection*. Related: [Is there a difference between the generic bounds “Enum & Foo” and “Enum extends Foo>”](https://stackoverflow.com/questions/14122783/is-there-a-difference-between-the-generic-bounds-enumt-foo-and-enum-ext) – Bohemian Feb 08 '18 at 14:10
  • 1
    Nyranith your expalnation was very good – RaM PrabU Feb 08 '18 at 14:15

0 Answers0