This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Use static block when there is s a requirement to execute block of code when the class is loaded but before instantiating the class. If you write static block of code inside method then you must have instance of class to execute that method and the whole purpose of static initialization block is fail. Hence it will not allowed.
Joined: Sep 12, 2009
Oooops .....We have to follow the rules mentioned JAVA language designers.
Joined: Jul 16, 2010
okay ,the problem is resolved .Thanks for the solution.