Methods are used to for plenty of reasons:

  • Cleaner code
  • Code re-usability
  • Easier maintenance
  • Code readability


How does method actually look like?

Method consists of method signature and method body.


Method signature signature always look like this:

  • Access modifier
  • Return type or void
  • Method name
  • Parameters



And After method signature we have

  • Opening curly brackets
  • Method body/our logic
  • Closing curly brackets



Let’s dissect this method:


Our method could be void, meaning that method will not return any value.


Of course, our method can also be parameter-less, contain multiple parameters or with different access modifiers. We could also have multiple methods with same name but will have to have different parameters or at-least different order of same parameters.