Methods in Java
A method is just a block of code that be called anytime. It helps in keeping the code clean.
Anytime you have some code that will be called repeatedly, go ahead and create a method. You can then call this from any part of the code.
Let me show you a simple method. In the previous example, I showed main() method. We'll call this simple method from the main() method.
Note: the "void" here means this method returns nothing!
Running this code will print this line:
I am a simple method.
It's actually that simple, folks!