For further actions, you may consider blocking this person and/or reporting abuse
Read next
AWS SnapStart - Part 17 Impact of the snapshot tiered cache on the cold starts with Java 21
Vadym Kazulkin -
How to use JPA API Specification?
Jonathan Tavares -
AWS SnapStart - Part 16 Measuring cold and warm starts with Java 21 using different asynchronous HTTP clients
Vadym Kazulkin -
Groovy 🎷 Cheat Sheet - 01 Say "Hello" from Groovy
Fady GA 😎 -
Oldest comments (3)
Function is only that, method is a function inside a class.
A method is a function in a object oriented context.
Both of them refer to any chunk of code that can be reused again with different arguments and may or may not cause side effects. Traditionally called a "subroutine". They are named differently because of the different context they appear within.
A method is a subroutine that is part of the instantiation of a class (an object) in an object oriented programming language, whereas a function is a subroutine not tied to any class/object. They are also referred to as free functions sometimes.
Another thing to know from the functional programming aspect is that functions have a property that they cannot cause side effects.
Method can only be called if you have an instance of some class, whereas to call a function all you need is to provide it the required arguments it needs.
Another interpretation: a method is just a function that receives the object instance as its first argument. (Ex: the self keyword in python)