Consider the following method that is intended to swap the values of two integers: public static void

Question:

Consider the following method that is intended to swap the values of two integers:

public static void falseSwap(int a, int b)
{
int temp = a;
a = b;
b = temp;
}
public static void main(String[] args)
{
int x = 3;
int y = 4;
falseSwap(x, y);
System.out.println(x + " " + y);
}
Why doesn’t the falseSwap method swap the contents of x and y?

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: