aspose file tools*
The moose likes Java in General and the fly likes when static initialization occurs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "when static initialization occurs" Watch "when static initialization occurs" New topic
Author

when static initialization occurs

Nick George
Ranch Hand

Joined: Apr 04, 2004
Posts: 815
consider, if you will, the following code:



if teams is run multiple times, I receive the following output:

[null, null, null, null, null, null]
[Loonies, null, null, null, null, null]
[Loonies, Dingbats, null, null, null, null]
[Loonies, Dingbats, Simpletons, null, null, null]
[Loonies, Dingbats, Simpletons, Wonkers, null, null]
[Loonies, Dingbats, Simpletons, Wonkers, Plonkers, null]
[Loonies, Dingbats, Simpletons, Wonkers, Plonkers, Melee]

why does it take it sudurn' long to get it right?


I've heard it takes forever to grow a woman from the ground
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Could you provide the whole program that runs the code that you gave above? I think the list should add the teams in order as specified once the method returns... I'm not quite sure why your teams() method behaves like this...

Providing more code snippets might help us to find out the details, I guess...


Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
Petr Blahos
Ranch Hand

Joined: Apr 28, 2004
Posts: 131
Let me guess. This is the missing part:



;-)
I can reassure you, everything is working perfectly. It's
your core which is a bit unfortunate. The static variables
are initialized as soon as classloader loads the class. The
rest is explained in your signature.

P.


Get a better web browser:<br /><a href="http://www.mozilla.org/products/firefox/switch.html" target="_blank" rel="nofollow">http://www.mozilla.org/products/firefox/switch.html</a>
Nick George
Ranch Hand

Joined: Apr 04, 2004
Posts: 815
check
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Originally posted by Petr Blahos:
I can reassure you, everything is working perfectly. It's
your core which is a bit unfortunate. The static variables
are initialized as soon as classloader loads the class. The
rest is explained in your signature.


I got it as well...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: when static initialization occurs