prevent inheritance of static block

前端 未结 2 1862
粉色の甜心
粉色の甜心 2021-01-15 07:36

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 {
s         


        
2条回答
  •  星月不相逢
    2021-01-15 08:36

    its not possible. Static block is executing during class loading and you can't prevent this without refactoring the parent class to not used the static block

提交回复
热议问题