Methods in java

  • The only required elements of a method declaration are the method’s return type, name, a pair of parentheses, (), and a body between braces, {}.
  • Two of the components of a method declaration comprise the method signature—the method’s name and the parameter types.
  • The return type—the data type of the value returned by the method, or void if the method does not return a value.

Naming a Method

A method name can be any legal identifier, code conventions restrict method names. By convention, method names should be a verb in lowercase or a multi-word name that begins with a verb in lowercase, followed by adjectives, nouns, etc.

codingpoint
Naming a Method

A method has a unique name within its class. However, a method might have
the same name as other methods due to method overloading

Leave a Comment