Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class call {
- static void call_by_value(int a, int b)
- {
- int c = a;
- a = b;
- b = c;
- System.out.println("In call_by_value\na = " + a + " b = " + b);
- }
- static void call_by_ref(int ar, Integer br)
- {
- int a = ar, b = br, c;
- ar = br;
- c = a;
- a = b;
- b = c;
- System.out.println("In call_by_ref\na = " + a + " b = " + b);
- }
- public static void main(String[] args)
- {
- int a = 10, b = 20;
- System.out.println("In Main\na = " + a + " b = " + b);
- Integer a_ref = new Integer(10);
- Integer b_ref = new Integer(20);
- call_by_value(a, b);
- call_by_ref(a_ref, b_ref);
- System.out.println("Again, in Main\na = " + a_ref + " b = " + b_ref);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement