Skip to content

Commit ed7637f

Browse files
committed
feat: Demonstrate array mutability by modifying array through function call
🧠 Logic: - Passes an array `nums` to a method `change`. - The method modifies `arr[0] = 99`. - Since arrays are reference types in Java, the original array is modified. - Prints the array before and after the change to illustrate the effect. 📌 Highlights that Java passes object references by value, so modifications inside functions affect the original array. Signed-off-by: Somesh diwan <[email protected]>
1 parent 62cbbc6 commit ed7637f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Section9ArrayAB/Array IMP/PassinginFunctions.java renamed to Section9ArrayAB/Array IMP/PassingFunctions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import java.util.Arrays;
22

3-
public class PassinginFunctions {
3+
public class PassingFunctions {
44
public static void main(String[] args) {
55
int[] nums = {3, 4, 5, 12};
66
System.out.println(Arrays.toString(nums));

0 commit comments

Comments
 (0)