Procedures (Void Methods)


Void type

A procedure is similar to a function but it just does a job. It has no answer.

To create a procedure in Java, replace the type of the answer by void, which means that there is no answer. For example, here is a procedure that prints a greeting.

  public static void printGreeting( )
  {
    System.out.println("Guten Tag.");
  }


Terminology

In Java, functions and procedures are all called methods. Methods whose return type if void are called void methods. We will adopt that terminology from now on.


Summary

A void method acts like a procedure. It does not produce an answer.