making an instance before calling non static method in java

后端 未结 4 1570
长发绾君心
长发绾君心 2021-01-20 16:53

Hi could someone please explain to me why you have to create an instance before calling a non static method to the main function in java? What is the reasoning behind this?<

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-20 17:02

    Static methods are class-level methods, so no instance is required.

    Non-static methods are instance methods. Hence an instance is required.

提交回复
热议问题