22.06 Methods and Functions

Methods and Functions

Overview

Methods in Java are blocks of code that perform specific tasks and can be reused.

Topics

Examples

public int add(int a, int b) {
    return a + b;
}

public static void greet() {
    System.out.println("Hello, World!");
}

Tags

#java #methods #functions #methodoverloading #staticmethods