| Author |
Reflection: To check whether static block is there or not!
|
Abhishek Chaudhari
Greenhorn
Joined: Feb 09, 2005
Posts: 11
|
|
**Hello.java public class Hello { public static void main(String[] args) { System.out.println("Hello World!"); } static { System.out.println("Static Block of Hello"); } } /////////////////////////// **Hello2.java public class Hello2 { public static void main(String[] args) { Class klass = Hello.class; ....... } } /////////////////// Can I somehow know - using reflection - in class Hello2 through 'klass' whether there is a static block in class Hello?
|
 |
Nathaniel Stoddard
Ranch Hand
Joined: May 29, 2003
Posts: 1258
|
|
|
Um ... I don't think so. Just curious though, but what possible reason would you have for wanting to know if there is a static initialization block in a class?
|
Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
|
 |
 |
|
|
subject: Reflection: To check whether static block is there or not!
|
|
|