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


Groups > comp.lang.java.help > #1288

Re: Enum basics

From Roedy Green <see_website@mindprod.com.invalid>
Newsgroups comp.lang.java.help
Subject Re: Enum basics
Date 2011-11-05 04:18 -0700
Organization Canadian Mind Products
Message-ID <1h6ab71vo4kgbblc8dnbl8dne9l35q80f2@4ax.com> (permalink)
References <3bo8b7dd306f6pj50v2jk3t9704n1c0cjp@4ax.com>

Show all headers | View raw


On Fri, 04 Nov 2011 15:11:45 -0700, Roedy Green
<see_website@mindprod.com.invalid> wrote, quoted or indirectly quoted
someone who said :

>Are enums supposed to support static variables? static methods?

I wrote an SSCCE to sort this out.  See
http://mindprod.com/jgloss/enum.html#VARIABLESCOPE

The bottom line is: enums can have static variables shared between all
enum constants and instance variables. Nested enums can access the
static final constants and static variables of the enclosing class,
but not its instance variables. static and instance methods behave
similarly. Implicitly, a nested enum is a nested static class, so this
is the expected behaviour.  
-- 
Roedy Green Canadian Mind Products
http://mindprod.com
Capitalism has spurred the competition that makes CPUs faster and 
faster each year, but the focus on money makes software manufacturers 
do some peculiar things like deliberately leaving bugs and deficiencies
in the software so they can soak the customers for upgrades later.
Whether software is easy to use, or never loses data, when the company
has a near monopoly, is almost irrelevant to profits, and therefore 
ignored. The manufacturer focuses on cheap gimicks like dancing paper 
clips to dazzle naive first-time buyers. The needs of existing 
experienced users are almost irrelevant. I see software rental as the 
best remedy.

Back to comp.lang.java.help | Previous | NextPrevious in thread | Find similar


Thread

Enum basics Roedy Green <see_website@mindprod.com.invalid> - 2011-11-04 15:11 -0700
  Re: Enum basics "John B. Matthews" <nospam@nospam.invalid> - 2011-11-04 20:44 -0400
    Re: Enum basics Lew <lewbloch@gmail.com> - 2011-11-04 20:27 -0700
      Re: Enum basics "John B. Matthews" <nospam@nospam.invalid> - 2011-11-05 02:23 -0400
        Re: Enum basics Lew <lewbloch@gmail.com> - 2011-11-05 00:51 -0700
      Re: Enum basics Roedy Green <see_website@mindprod.com.invalid> - 2011-11-05 04:12 -0700
        Re: Enum basics Lew <lewbloch@gmail.com> - 2011-11-05 09:15 -0700
          Re: Enum basics Patricia Shanahan <pats@acm.org> - 2011-11-05 14:06 -0700
            Re: Enum basics Lew <lewbloch@gmail.com> - 2011-11-05 15:54 -0700
            Re: Enum basics Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-11-05 20:43 -0300
            Re: Enum basics markspace <-@.> - 2011-11-05 19:55 -0700
            Re: Enum basics Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-11-05 22:10 -0500
  Re: Enum basics Roedy Green <see_website@mindprod.com.invalid> - 2011-11-05 04:18 -0700

csiph-web