What is the purpose of creating static object in Java?

前端 未结 5 2058
走了就别回头了
走了就别回头了 2021-02-06 10:36
class Demo {
   void show() {
      System.out.println(\"i am in show method of super class\");
   }
}
class Flavor1Demo {

   //  An anonymous class with Demo as base c         


        
5条回答
  •  别跟我提以往
    2021-02-06 10:45

    Thats because you try to use d that belongs to object in static method.

    You would then have to create that object in main method.

    static belongs to class, not object itself.

    I want to know the difference between static method and non-static method

提交回复
热议问题