Inheritance vs Static in Java

后端 未结 6 1897
温柔的废话
温柔的废话 2020-12-06 15:17

I dont quite understand why Static methods can be inherited in Java ?

Inheritance is like inheriting from the base class AND Static belongs to the Class and not Obje

6条回答
  •  我在风中等你
    2020-12-06 16:02

    public class StaticTest extends StaticBase {
    
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        System.out.println("Start");
        StaticTest.printIt();
    }
    

    }

    class StaticBase{

    public static void printIt(){
        System.out.println("Inside bas Class");
    }
    

    }

    Does this code not prove that Static is Inherited ??

提交回复
热议问题