From fab39307b045215fb465701009bb0d454788a4ca Mon Sep 17 00:00:00 2001 From: Kamal Wickramanayake Date: Sat, 21 Feb 2026 19:56:23 +0530 Subject: Added simple OOP sample code. --- oop/08-pass-by-value-reference/PassByValue.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 oop/08-pass-by-value-reference/PassByValue.java (limited to 'oop/08-pass-by-value-reference/PassByValue.java') diff --git a/oop/08-pass-by-value-reference/PassByValue.java b/oop/08-pass-by-value-reference/PassByValue.java new file mode 100644 index 0000000..2500d03 --- /dev/null +++ b/oop/08-pass-by-value-reference/PassByValue.java @@ -0,0 +1,17 @@ +public class PassByValue { + + /** + * @param args + */ + public static void main(String[] args) { + int x = 4; + System.out.println(x); // 4 + method(x, 2); + System.out.println(x); // ? + } + + public static void method(int x, int b) { + x = x + 1; + System.out.println(x); // 5 + } +} -- cgit v1.2.3