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

How to call static block without creating initiating a class

 
Bk Jacky
Ranch Hand
Posts: 74
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rancher,

I have some classes with static blocks(having some variables in side).I want to initiate variables inside static block without creating object of that particular class. I know that i have to load a class in the memory but how?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are several ways to load a class without creating an instance of the class. One simple, direct method is this:

Class.forName("com.the.ClassName");

Just calling the static "forName()" method in java.lang.Class, passing the class's name as a String, will load that class for you.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic