Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Knute Johnson Newsgroups: comp.lang.java.programmer Subject: Re: enum syntax Date: Sat, 7 May 2016 21:43:54 -0700 Organization: A noiseless patient Spider Lines: 48 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 8 May 2016 04:40:24 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="fc10d1b501433caa198830294d826923"; logging-data="1450"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/99lDEfhys8KNZVAUHRveu" User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.0 In-Reply-To: Cancel-Lock: sha1:BPANzZDJ9VsWAkYFwabc7fcNmv0= Xref: csiph.com comp.lang.java.programmer:34261 On 5/7/2016 20:58, ruben safir wrote: > How is there no closing paran and a method included as an enum entry? > > what is this syntax ? > > > /** > * An enumeration representing all base types in Calc. It also includes > * the ERROR designation, used by the type checker to propagate errors. > */ > public enum Type { > INT, > FLOAT, > BOOL, > STRING, > ERROR; > > /** > * The types form a hierarchy, with ERROR at the root. > * @return The least upper bound of this and that. > */ > public Type leastUpperBound(Type that) { > if(this == that) > return this; > if((this == INT && that == FLOAT) > ||(this == FLOAT && that == INT)) > return FLOAT; > return ERROR; > } > > /** > * Determines whether the type is numeric, defined as INT or FLOAT. > */ > public boolean isNumeric() { > return leastUpperBound(FLOAT) == FLOAT; > } > } > From the JLS "In addition to enum constants, the body of an enum declaration may contain constructor and member declarations as well as instance and static initializers." See JLS 8.9.2. -- Knute Johnson