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


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

Re: static data for methods...

From Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at>
Newsgroups comp.lang.java.programmer
Subject Re: static data for methods...
Date 2013-10-09 15:42 +0000
Organization A noiseless patient Spider
Message-ID <slrnl5aubc.mol.avl@gamma.logic.tuwien.ac.at> (permalink)
References <slrnl5ape4.mol.avl@gamma.logic.tuwien.ac.at> <4ca67dcc-303b-410b-a26d-2e7312338ba2@googlegroups.com>

Show all headers | View raw


taqmcg@gmail.com <taqmcg@gmail.com> wrote:
> On Wednesday, October 9, 2013 10:18:43 AM UTC-4, Andreas Leitgeb wrote:
>> I'm aware that in Java, methods cannot have static data within
>> them.  The usual "workaround" is to place static data for a
>> method in static fields of the class.  However, I need the
>> static fields lexically separated for the methods.
>
> If you really want a separate name space for each function you
> could use the name spacing provided in nested classes.

Stefan Ram already scored a better(*) hit:
(*): according to my (OP's) subjective preferences

Stefan's approach (slightly adapted):

 class Primary {
     static class Method1 {
         static char someVar; ... 
         void method1() {
            char xx = someVar; ... // no qualification needed
         }
     }
     void method1() { Method1.method(); } // simple wrapper @ toplevel
     
     ...
 }

Thanks, anyway!

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


Thread

static data for methods... Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-10-09 14:18 +0000
  Re: static data for methods... taqmcg@gmail.com - 2013-10-09 07:49 -0700
    Re: static data for methods... Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-10-09 15:42 +0000
  Re: static data for methods... Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-10-09 15:29 +0000
  Re: static data for methods... Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2013-10-10 14:44 +0200
    Re: static data for methods... Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-10-10 13:13 +0000
      Re: static data for methods... Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2013-10-10 15:44 +0200
        Re: static data for methods... Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-10-10 17:26 +0000
  Re: static data for methods... Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2013-10-11 22:03 -0700
    Re: static data for methods... Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2013-10-18 15:31 +0000

csiph-web