posted 14 years ago
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.
Life is easy because we write the source code.....