ELI5: Explain Like I'm 5

Method (computer programming)

A method is like a recipe that a computer follows to do something. Just like how a chef follows a recipe to cook something, a computer follows a method to solve a problem or do a task. It's a set of instructions that tells the computer what steps to take in order to complete a particular job. For example, if you want the computer to say "hello" to you, you would create a method called "sayHello" that would tell the computer to print the word "hello" on the screen. Methods are really useful when you need to do a task over and over again because you can just call the method instead of writing out all the instructions every time. It’s like having a magic spell that makes the computer do exactly what you want it to do!
Related topics others have asked about: