Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Static Initializer / methoed

 
Frank Jacobsen
Ranch Hand
Posts: 358
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Example:

Can someone tell me if i can be 100 % that the first time i call this class from a other java class, using Prefill.getPrefilled that the static initializer block is done once and only once, before continueing whit the code in the getPrefilled methoed !
Edited by Corey McGlone: Added Code Tags
[ April 07, 2003: Message edited by: Corey McGlone ]
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Frank Jacobsen:
Can someone tell me if i can be 100 % that the first time i call this class from a other java class, using Prefill.getPrefilled that the static initializer block is done once and only once, before continueing whit the code in the getPrefilled methoed !

The static initializer is called once and only once when the class is loaded and before the body of any static method is processed and before any instance is constructed. To prove it to yourself, just write a short program that prints a message from the static initializer and also prints a message from the static method that you are interested in. If you would like to see some sample programs that demonstrate the behavior of initializers, the please see "Chapter 8: initializers", at the following URL.
http://www.danchisholm.net/dec04/guide/mughal/index.html
A note to those studying for the exam: although Mughal has included this topic in his book and although I have included it in my mock exam, it is really a little beyond the scope of the exam.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic