Pass by Value

Pass by Value — Means that when you pass a variable to a method, Java creates a copy of that variable's value.

Public class PassByValueExample {
    public static void main(String[] args) {
        int original = 5;
        modifyValue(original);
        System.out.println("After modifyValue: " + original); // Outputs: 5
    }

    public static void modifyValue(int number) {
        number = 10;
    }
}

Related concepts

Pass by Value — Structure map

Clickable & Draggable!

Pass by Value — Related pages: