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


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

Re: java code

Newsgroups comp.lang.java.programmer
Date 2014-02-25 15:08 -0800
References (1 earlier) <1o6dnRRLlOIZI5TOnZ2dnUVZ7oednZ2d@bt.com> <79f3dad1-4e94-434c-83f1-6c0eeff87ec3@googlegroups.com> <I9udneg4xs0YlpbOnZ2dnUVZ8lednZ2d@bt.com> <530be291$0$303$14726298@news.sunsite.dk> <w6Kdnax3lfJL_ZHOnZ2dnUVZ7r6dnZ2d@bt.com>
Message-ID <b10f2fc3-c878-4b42-b5ac-688eee56d53c@googlegroups.com> (permalink)
Subject Re: java code
From Lew <lewbloch@gmail.com>

Show all headers | View raw


lipska the kat wrote:
> Arne Vajhøj wrote:
>> He did not say const - he said constant.
>> Which per JLS and normal Java terminology means static final.

Nope. It does not.

It means a primitive or String literal, an expression involving constants, or a 'final' variable initialized with a constant expression. It need not be 'static'.

> The variable concerned has block scope within main.
> You cannot apply the static modifier here.

Lipska, you should study Java before blathering. You make no sense.

If you don't even know what a "constant" is in Java, you need to study more.

> static final int increment = 11;
> 
> my compiler says no with
> Illegal modifier for parameter increment only final is permitted	

So don't say 'static', duh.

C'mon, learn Java already!

> So, you *could say*
> final int increment
> however this is not a constant because it's (potential) value is not 
> known at the time of declaration, at this point it is a 'variable'

Right. So?

> later you can say (for example)
> 
> increment = Integer.parseInt(args[1]);
> 
> Now it's a final int but not a constant according to you via apparently 
> the JLS and 'normal Java terminology'

Disingenuous. Work from the *actual* definition of "constant" in Java, please.

> You could increase the visibility of increment to class scope, then you 
> *can* say
> static final int increment = 11;

And that would be a "constant variable" in Java.

> but you can also say
> static final int increment;

> increment is not a constant, it's an uninitialized static final int, 
> there's a difference.

Yes. That's in the JLS.

> You can then say

> increment = 11;
> However this would make the scope of increment wider which is another 
> Bloch no no.

This has nothing to do with what I said, which was "use a constant". 

> Obviously I can't prove the following in Java as the reserved word const 
> is unused so I'll use C

Irrelevant. Ignored.

> So then Arne, how exactly would you make the variable increment constant 
> within main using your own criteria of a 'constant' in Java being static 
> final.

Actually, he'd use the Java definition, not the mistaken one.

> As always I'll be delighted to be shown how wrong I am.

Yeah, right.

You're wrong because you aren't talking about Java constants.

I said to use a constant. Let's address that advice, hm?

-- 
Lew

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


Thread

java code "jay'el antonio" <jlantonio10@gmail.com> - 2014-02-20 16:03 -0800
  Re: java code Stuart <DerTopper@web.de> - 2014-02-21 14:29 +0100
    Re: java code Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2014-02-22 01:10 -0600
      Re: java code Jan Burse <janburse@fastmail.fm> - 2014-02-22 12:36 +0100
      Re: java code Stuart <DerTopper@web.de> - 2014-02-22 13:57 +0100
        Re: java code Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2014-02-22 12:05 -0600
          Re: java code Stuart <DerTopper@web.de> - 2014-02-22 20:02 +0100
    Re: java code Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2014-02-23 00:52 -0800
  Re: java code Roedy Green <see_website@mindprod.com.invalid> - 2014-02-21 08:55 -0800
  Re: java code lipska the kat <lipskathekat@example.com> - 2014-02-23 09:25 +0000
    Re: java code Lew <lewbloch@gmail.com> - 2014-02-23 20:47 -0800
      Re: java code lipska the kat <lipskathekat@example.com> - 2014-02-24 09:06 +0000
        Re: java code Arne Vajhøj <arne@vajhoej.dk> - 2014-02-24 19:23 -0500
          Re: java code lipska the kat <lipskathekat@example.com> - 2014-02-25 09:22 +0000
            Re: java code Lew <lewbloch@gmail.com> - 2014-02-25 15:08 -0800
              Re: java code lipska the kat <lipskathekat@example.com> - 2014-02-26 08:47 +0000
        Re: java code leif.roar@invalid.com (Leif Roar Moldskred) - 2014-02-25 03:56 -0600
    Re: java code Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2014-02-25 14:54 -0800
      Re: java code lipska the kat <lipskathekat@example.com> - 2014-02-26 09:07 +0000
        Re: java code Simon Lewis <simonlewis2001@gmail.com> - 2014-02-26 12:40 +0100
      Re: java code lipska the kat <lipskathekat@example.com> - 2014-02-26 14:54 +0000
        Re: java code Simon Lewis <simonlewis2001@gmail.com> - 2014-02-26 16:10 +0100
          Re: java code lipska the kat <lipskathekat@example.com> - 2014-02-26 15:45 +0000
            Re: java code Robert Klemme <shortcutter@googlemail.com> - 2014-02-27 14:01 +0100
            Re: java code Simon Lewis <simonlewis2001@gmail.com> - 2014-02-27 14:48 +0100
              Re: java code leif.roar@invalid.com (Leif Roar Moldskred) - 2014-02-27 09:49 -0600
              Re: java code Joerg Meier <joergmmeier@arcor.de> - 2014-02-27 19:24 +0100
          Re: java code Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2014-02-26 12:53 -0800
          Re: java code Lew <lewbloch@gmail.com> - 2014-02-28 16:10 -0800
            Re: java code lipska the kat <lipskathekat@example.com> - 2014-03-01 08:36 +0000
              Re: java code "Qu0ll" <Qu0llSixFour@gmail.com> - 2014-03-01 20:51 +1100
                Re: java code lipska the kat <lipskathekat@example.com> - 2014-03-01 10:31 +0000
                Re: java code "Qu0ll" <Qu0llSixFour@gmail.com> - 2014-03-01 21:44 +1100
                Re: java code lipska the kat <lipskathekat@example.com> - 2014-03-01 10:49 +0000
                Re: java code "Qu0ll" <Qu0llSixFour@gmail.com> - 2014-03-01 21:58 +1100
                Re: java code lipska the kat <lipskathekat@example.com> - 2014-03-01 12:00 +0000
                Re: java code "Qu0ll" <Qu0llSixFour@gmail.com> - 2014-03-02 11:36 +1100
        Re: java code Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2014-02-26 12:59 -0800
    Re: java code David Lamb <dalamb@cs.queensu.ca> - 2014-02-28 20:42 -0500
      Re: java code lipska the kat <lipskathekat@example.com> - 2014-03-01 08:58 +0000
        Re: java code "Qu0ll" <Qu0llSixFour@gmail.com> - 2014-03-01 21:00 +1100
          Re: java code lipska the kat <lipskathekat@example.com> - 2014-03-01 10:45 +0000
            Re: java code "Qu0ll" <Qu0llSixFour@gmail.com> - 2014-03-01 22:04 +1100
              Re: java code lipska the kat <lipskathekat@example.com> - 2014-03-01 12:13 +0000
                Re: java code "Qu0ll" <Qu0llSixFour@gmail.com> - 2014-03-02 11:05 +1100
                Re: java code lipska the kat <lipskathekat@example.com> - 2014-03-02 08:57 +0000
                Re: java code "Qu0ll" <Qu0llSixFour@gmail.com> - 2014-03-02 22:02 +1100
                Re: java code lipska the kat <lipskathekat@example.com> - 2014-03-02 11:57 +0000
                Re: java code leif.roar@invalid.com (Leif Roar Moldskred) - 2014-03-02 06:57 -0600
        Re: java code David Lamb <dalamb@cs.queensu.ca> - 2014-03-02 15:21 -0500
  Re: java code rossum <rossum48@coldmail.com> - 2014-02-26 22:06 +0000
    Re: java code "Qu0ll" <Qu0llSixFour@gmail.com> - 2014-02-27 14:01 +1100
  Re: java code v_borchert@despammed.com (Volker Borchert) - 2014-03-01 19:52 +0000

csiph-web