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 =
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?
Step by Step Solution
3.40 Rating (166 Votes )
There are 3 Steps involved in it
public static void falseSwapint a int b int temp a a b b temp public static ... View full answer
Get step-by-step solutions from verified subject matter experts
