Java program for pass by value or call by value

 class Args2

{

    static void swap(int a, int b)

    {

        int t = a;

        a = b;

        b = t;

    }

    public static void main(String[] args) 

    {

        int x = 5,y = 7;

        System.out.println("x = "+x+" y = "+y);

        swap(x,y);

        System.out.println("x = "+x+" y = "+y);

    }

}



OUTPUT





Comments