Разница между статическими методами и методами экземпляра

Я просто перечитывал текст, данный мне в моем учебнике, и я не совсем уверен, что понимаю, о чем он говорит. По сути, это говорит мне, что статические методы или методы класса включают ключевое слово «модификатор» static. Но я действительно не знаю, что это значит?

Может ли кто-нибудь объяснить мне очень простыми словами, что такое статические или классовые методы?

Кроме того, могу ли я получить простое объяснение того, что такое методы экземпляра?

Вот что мне дают в учебнике:

There are important practical implications of the presence or absence of the static modifier. A public class method may be invoked and executed as soon as Java processes the definition of the class to which it belongs. That is not the case for an instance method. Before a public instance method may be invoked and executed, an instance must be created of the class to which it belongs. To use a public class method, you just need the class. On the other hand, before you can use a public instance method you must have an instance of the class.

The manner in which a static method is invoked within the definition of another method varies according to whether or not the two methods belong to the same class. In the example above, factorial and main are both methods of the MainClass class. As a result, the invocation of factorial in the definition of main simply references the method name, "factorial".

81
задан Platinum Azure 24 November 2014 в 23:10
поделиться