Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #2858
| X-Received | by 10.182.186.73 with SMTP id fi9mr1137971obc.48.1384815114407; Mon, 18 Nov 2013 14:51:54 -0800 (PST) |
|---|---|
| X-Received | by 10.182.96.135 with SMTP id ds7mr234592obb.1.1384815114328; Mon, 18 Nov 2013 14:51:54 -0800 (PST) |
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!peer02.iad.highwinds-media.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!i2no5361907qav.0!news-out.google.com!9ni35979qaf.0!nntp.google.com!dz2no722425qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
| Newsgroups | comp.lang.java.help |
| Date | Mon, 18 Nov 2013 14:51:54 -0800 (PST) |
| In-Reply-To | <8ed39e6c-ccea-480e-b3a3-8b802957ede8@googlegroups.com> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=77.251.156.172; posting-account=tRhYkQoAAAC4mfP99Qw2QppE0qHeI37Z |
| NNTP-Posting-Host | 77.251.156.172 |
| References | <8ed39e6c-ccea-480e-b3a3-8b802957ede8@googlegroups.com> |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <ca817691-9fe0-41d4-8da0-8cb8fc7e1bf5@googlegroups.com> (permalink) |
| Subject | Re: how to access static instance variables defined in static initializer block |
| From | Marc B <marc.at.compass@gmail.com> |
| Injection-Date | Mon, 18 Nov 2013 22:51:54 +0000 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-Received-Bytes | 1739 |
| X-Received-Body-CRC | 3244454837 |
| Xref | csiph.com comp.lang.java.help:2858 |
Show key headers only | View raw
Ok,. I found an answer..
I have to _declare_ te static variables outside te static initializer block and _initialize_ them in the static initializer
static int sint2 = 8;
static {
sint2 = 8;
System.out.println("Initializing static variable sint2: " + sint2);
}
Then I can refer to Holder.sint2.
//
Still don't see why adding static int sint2 = 8; to contructor or main() doesn't work:
public Holder(){
static int sint2 = 9;
}
Marc
Back to comp.lang.java.help | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
how to access static instance variables defined in static initializer block Marc B <marc.at.compass@gmail.com> - 2013-11-18 14:42 -0800
Re: how to access static instance variables defined in static initializer block Marc B <marc.at.compass@gmail.com> - 2013-11-18 14:51 -0800
Re: how to access static instance variables defined in static initializer block Marc B <marc.at.compass@gmail.com> - 2013-11-18 15:01 -0800
Re: how to access static instance variables defined in static initializer block markspace <markspace@nospam.nospam> - 2013-11-18 15:26 -0800
Re: how to access static instance variables defined in static initializer block Lew <lewbloch@gmail.com> - 2013-11-27 16:05 -0800
Re: how to access static instance variables defined in static initializer block Roedy Green <see_website@mindprod.com.invalid> - 2013-11-30 12:41 -0800
Re: how to access static instance variables defined in static initializer block Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2013-12-01 00:23 +0200
csiph-web