Why functions are called methods in java?

This question already has an answer here:

  • Difference between a method and a function 33 answers

  • It's not in Java, it's an OOP name.

    In sort, it defines part of the behavior of an instance of an object, not a general operation.


    Every language has it's own syntax to differentiate from others. As for your question

    Functions existence is independent.

    Methods do not as they are created within the class.


    Why functions are called methods in java?

  • A method is on an object.
  • A function is independent of an object.
  • For Java, there are only methods.
  • For C, there are only functions.
  • For C++ it would depend on whether or not you're in a class.

    In languages such as C++, functions are bits of code that will perform a particular action - but are not associated with an object. functions that are to do with an object are called methods. in java all functions are methods as they are all to do with objects.

    链接地址: http://www.djcxy.com/p/17314.html

    上一篇: 功能和方法之间的区别

    下一篇: 为什么函数在java中被称为方法?