• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

when static initialization occurs

 
Ranch Hand
Posts: 815
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Nick George
Ranch Hand
Posts: 815
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
check
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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...
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic