Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #34261
| From | Knute Johnson <nospam@rabbitbrush.frazmtn.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: enum syntax |
| Date | 2016-05-07 21:43 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <ngmfvn$1da$1@dont-email.me> (permalink) |
| References | <ngmdhi$ics$1@reader1.panix.com> |
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
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
enum syntax ruben safir <ruben@mrbrklyn.com> - 2016-05-07 23:58 -0400
Re: enum syntax Knute Johnson <nospam@rabbitbrush.frazmtn.com> - 2016-05-07 21:43 -0700
Re: enum syntax Roedy Green <inquiry@mindprod.com> - 2016-07-12 04:35 -0700
Re: enum syntax Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-05-08 07:22 -0400
Re: enum syntax Roedy Green <see_website@mindprod.com.invalid> - 2016-05-20 18:01 -0700
csiph-web