- {
- static
- }
- }
//Demo for
init block and static init block .
- class InitDemo {
- InitDemo(int x) {
- System.out.println("1-arg const");
- }
- InitDemo() {
- System.out.println("no-arg const");
- }
- static {
- System.out.println("static init block");
- } {
- System.out.println("First Instance init block");
- }
- public static void main(String[] args) {
- System.out.println("Main Started");
- InitDemo obj = new InitDemo();
- InitDemo obj2 = new InitDemo(7);
- }
- }
Output



Gowtham RajamanickamTOP 100Posted May 18, 2015, 8:47 PM EDT
intresting
Gowtham RajamanickamTOP 100Posted May 18, 2015, 8:47 PM EDT
good one