Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #31613

Re: enum, what is it good for?

From Sebastian <news@seyweiler.dyndns.org>
Newsgroups comp.lang.java.programmer
Subject Re: enum, what is it good for?
Date 2015-04-24 22:49 +0200
Organization albasani.net
Message-ID <mhea9b$j9u$1@news.albasani.net> (permalink)
References <enum-20150421042614@ram.dialup.fu-berlin.de> <cpvgbcFaqjeU1@mid.individual.net>

Show all headers | View raw


Am 24.04.2015 20:28, schrieb Robert Klemme:
> On 21.04.2015 04:30, Stefan Ram wrote:
>
>>    So, is there any reason to prefer »enum« to »class«?
>
> Additionally to what others have said in favor of enums already, you can
> *very* concisely override methods in enum instances which is helpful for
> implementing state, strategy and similar patterns.  With classes that
> will look a lot more bulky.
>
> Kind regards
>
>      robert
>
can you elaborate on that? In what way is overriding an Enum method more 
concise than overriding an ordinary class method?

In any case, I am delighted that it is not too late to discuss Java 5 
features. Here's a short Enum-related blog post from May 2008 which I 
have always liked:

http://tobega.blogspot.de/2008/05/beautiful-enums.html

Too bad we have lambdas now.

-- Sebastian



Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: enum, what is it good for? Robert Klemme <shortcutter@googlemail.com> - 2015-04-24 20:28 +0200
  Re: enum, what is it good for? Sebastian <news@seyweiler.dyndns.org> - 2015-04-24 22:49 +0200
    Re: enum, what is it good for? Robert Klemme <shortcutter@googlemail.com> - 2015-04-25 10:41 +0200

csiph-web