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


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

Re: local constants with switch

X-Received by 10.182.251.135 with SMTP id zk7mr2997399obc.14.1407864666189; Tue, 12 Aug 2014 10:31:06 -0700 (PDT)
Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!h18no12177193igc.0!news-out.google.com!j6ni45219qas.0!nntp.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date Tue, 12 Aug 2014 12:31:05 -0500
Date Tue, 12 Aug 2014 20:30:54 +0300
From Donkey Hottie <donkey@fredriksson.dy.fi>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0
MIME-Version 1.0
Newsgroups comp.lang.java.programmer
Subject Re: local constants with switch
References <slrnlukhpi.fp3.avl@login.logic.tuwien.ac.at>
In-Reply-To <slrnlukhpi.fp3.avl@login.logic.tuwien.ac.at>
Message-ID <ejvpbb-g5s.ln1@tempest.fredriksson.dy.fi> (permalink)
Lines 24
X-Usenet-Provider http://www.giganews.com
X-Trace sv3-eoRQDRnpaWjdjnfDLP55LO+JDsomn3bNs2Jcp+ez6vg6k4PgBvpMnNQJfM7El+d3S6LOsUlhswmuVr6!9Q5m/4V//A1zFHrkcNzGii5r9WMEVGRHJD7o3FYHm0QVcMRTH1mhdIWdcc/2XPtky8Nn2A==
X-Complaints-To abuse@giganews.com
X-DMCA-Notifications http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info Otherwise we will be unable to process your complaint properly
X-Postfilter 1.3.40
X-Original-Bytes 2188
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
Xref csiph.com comp.lang.java.programmer:29644

Show key headers only | View raw


12.08.2014, 19:56, Andreas Leitgeb kirjoitti:
> It never before occurred to me, that one could define a local constant
> within a method (e.g.: final int foo = 42;) AND use it for a case label
> in a switch statement.
> 
> I'm a bit curious about whether this is an old-age feature that I've
> been missing out for a very long time, or if this just came in recently...
> 
> I had a look at the JLS, too: the description of switch(§14.11) refers to
> term constant expression (§15.28), which further refers to constant
> variables (§4.12.4), which is about final variables generally.
> 
> From that it wouldn't even be necessary for that variable to be itself
> initialized with a constant expression, but I probably just missed that
> wording, because it (expectably) doesn't work with a final whose initial
> value is not a constant expression itself, nor with a final variable
> that isn't immediately initialized.
> 

Scope. If it is in the scope it is valid.

-- 

You will gain money by an immoral action.

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


Thread

local constants with switch Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-12 16:56 +0000
  Re: local constants with switch Donkey Hottie <donkey@fredriksson.dy.fi> - 2014-08-12 20:30 +0300
  Re: local constants with switch Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-12 21:15 +0000
    Re: local constants with switch Silvio <silvio@internet.com> - 2014-08-12 23:20 +0200
    Re: local constants with switch Silvio <silvio@internet.com> - 2014-08-12 23:22 +0200
  Re: local constants with switch Lew <lewbloch@gmail.com> - 2014-08-15 15:22 -0700
    Re: local constants with switch Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-16 00:24 +0000
      Re: local constants with switch Roedy Green <see_website@mindprod.com.invalid> - 2014-08-18 23:46 -0700
        Re: local constants with switch Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-21 13:57 +0000
          Re: local constants with switch Joerg Meier <joergmmeier@arcor.de> - 2014-08-21 18:52 +0200
            Re: local constants with switch Mike Amling <mamling@chaff.us> - 2014-08-21 13:19 -0500
              Re: local constants with switch Joerg Meier <joergmmeier@arcor.de> - 2014-08-21 22:41 +0200
            [OT] Re: local constants with switch Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-08-21 14:42 -0400
              Re: [OT] Re: local constants with switch Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-21 19:21 +0000
                Re: [OT] Re: local constants with switch Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2014-08-21 22:30 -0500
                Re: [OT] Re: local constants with switch Silvio <silvio@internet.com> - 2014-08-23 14:01 +0200
                Re: [OT] Re: local constants with switch Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-23 15:22 +0000
              Re: [OT] Re: local constants with switch Arne Vajhøj <arne@vajhoej.dk> - 2014-08-23 22:12 -0400
          Re: local constants with switch Jim Gibson <jimsgibson@gmail.com> - 2014-08-21 17:04 -0700
            [OT] Re: local constants with switch Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-08-21 20:50 -0400
              Re: [OT] Re: local constants with switch Martin Gregorie <martin@address-in-sig.invalid> - 2014-08-22 11:48 +0000
  Re: local constants with switch Joerg Meier <joergmmeier@arcor.de> - 2014-08-16 01:18 +0200
    Re: local constants with switch Arne Vajhøj <arne@vajhoej.dk> - 2014-08-15 22:44 -0400
      Re: local constants with switch Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-16 09:01 +0000
        Re: local constants with switch Joerg Meier <joergmmeier@arcor.de> - 2014-08-16 12:08 +0200
        Re: local constants with switch Arne Vajhøj <arne@vajhoej.dk> - 2014-08-16 20:39 -0400
          Re: local constants with switch Joerg Meier <joergmmeier@arcor.de> - 2014-08-17 13:08 +0200
      Re: local constants with switch Joerg Meier <joergmmeier@arcor.de> - 2014-08-16 12:07 +0200
  Re: local constants with switch Arne Vajhøj <arne@vajhoej.dk> - 2014-08-15 22:42 -0400
    Re: local constants with switch Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-08-16 09:17 +0000

csiph-web