Organize Code

Function

Java

 

Defining Function

Java 8
public class MyClass {
  
  public static void main(String[] args) {
    greet();      // Hello World!
  }
  
  public static void greet() {
    System.out.println("Hello World!");
  }
  
}

Java is a class-based, Object-oriented Programming Language.

Java only supports Methods and not Functions (compared to Languages like C++ which have both concepts).

To learn more check out Method Topic.