If we run derived class,it will print derived and parent..is there any way to prevent inheritance of static block ?
//Class 1
public class parent {
static {
System.out.println("Parent");
}
}
//Class2
public class derived extends parent{
static {
System.out.println("derived");
}
public static void main(String [] args) {
}
}
Basically I have some method in parent class which I want to inherit but dont want the processing which is happening in parent static block to happen when derived class is being instantiated. .Is there any way to do this or I will have to duplicate the code ?