This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

static variables and blocks

 
Rob Petterson
Ranch Hand
Posts: 149
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone tell me if static variables take priority over static blocks ie which one gets initialized first?
 
Guoqiao Sun
Ranch Hand
Posts: 317
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I know, static variables and static blocks get initialized with the sequence they coded. No priority to each other.
regards,
Sun Guoqiao
Originally posted by Rob Petterson:
Can anyone tell me if static variables take priority over static blocks ie which one gets initialized first?
 
Rob Petterson
Ranch Hand
Posts: 149
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Guoqiao for clearing that up. I thought that was the case, but it's always good to get a second opinion.
 
Corey McGlone
Ranch Hand
Posts: 3271
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guoqiao is correct. Member initalizers and initializer block are executed in textual order. This is the case for both instance initializers and static initializers.
Corey
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic