https://qiita.com/hp_kj/items/85b911688155f9fc251a#comment-4a8cf9d5132387ed5106
As you pointed out here, I couldn't understand the function and method and searched.
According to the IT terminology encyclopedia
A function is a group of instructions that receives data called arguments, executes the specified processing, and returns the result.
A method is an operation on itself that each object has in object-oriented programming. It seems that it means something like that.
//Method definition
class Add {
int add(int x,int y) {
return x + y;
}
}
//Method call
public class Main {
public static void main(String[]args) {
Add a = new Add();
a.add(1, 3);
}
}
public class Main {
//Function definition
int add(int x, int y) {
return x + y;
}
//Function call
int c = add(1,2);
}
I think that it looks like this with java. A function when the function is used in the same class. When a function is defined in a class, an instance is created from that class, and it is used in another class, it is called a method.
I was allowed to reference. https://qiita.com/T-N0121/items/ecf5b911463ac9fa1d3e