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


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

Re: Enum basics

From "John B. Matthews" <nospam@nospam.invalid>
Newsgroups comp.lang.java.help
Subject Re: Enum basics
Date 2011-11-04 20:44 -0400
Organization The Wasteland
Message-ID <nospam-E313EF.20444304112011@news.aioe.org> (permalink)
References <3bo8b7dd306f6pj50v2jk3t9704n1c0cjp@4ax.com>

Show all headers | View raw


In article <3bo8b7dd306f6pj50v2jk3t9704n1c0cjp@4ax.com>,
 Roedy Green <see_website@mindprod.com.invalid> wrote:

> Are enums supposed to support static variables? static methods?
> 
> If the enum is nested in another class, are enum methods supposed to
> be able to access the containing classes instance variables and
> methods?
> 
> I believe the answer is "no" to all these questions, but I don't want
> to lead people astray in my essay on enums.

I believe the answer is yes to all three, as suggested here:

<http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.9>
<http://stackoverflow.com/questions/1973018>
<http://groups.google.com/group/comp.lang.java.help/msg/6c3a3d7a27be6331>

As a practical matter, I've never had cause to access enclosing class 
members from an enum.

> You have to communicate with the enum via the initial constructor, or
> by parms on enum methods.

I found it helpful to recall that "An enum type has no instances other 
than those defined by its enum constants."

-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>

Back to comp.lang.java.help | Previous | NextPrevious in thread | Next 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