Java Advanced Programming Tutorial 6 Setting Values To Enum

preview_player
Показать описание
How to create an enum in java
Рекомендации по теме
Комментарии
Автор

I haven't programmed in Java for a while, but couldn't you have just assigned values like in C/C++?

enum Power {
WEAK = 1, MODERATE, STRONG
}

I'll have to fire up Eclipse and try it, but shouldn't that do the same thing you've done here?

tcbetka
Автор

No...it doesn't work! Silly Java...gotta be different. Looks like you do indeed need to use a ctor. So you've taught me something--thanks! It's been a few years since I've written much Java code, because I've been writing C/C++ and C#. ;)

tcbetka