A method is a reusable block of code that performs a specific task.
A method has a return type, name, and optional parameters.
Parameters allow methods to accept input values.
Methods can return values instead of just printing them.
In Java, methods can be either static or non-static.
Main.greet();In the example below, sayHello() is a non-static method. That is why we create an object t using new Test() before calling it.
Key takeaway:
Create a method that returns the maximum of two numbers.