【发布时间】:2019-08-11 01:40:43
【问题描述】:
public class freedom {
public static void main(String args[]){
int x = 10;
int y = 20;
System.out.println(" x is: "+x+" y is: "+y);
swap(x,y);
System.out.println(" x is: "+x+" y is: "+y);
}
public static void swap(int x, int y){
int temp = x;
x = y;
y = temp;
}
}
所以我写了一个简单的函数来交换两个值,但由于某种原因它们没有被交换。我知道我的代码逻辑是正确的,但我想知道为什么没有交换这些值。
【问题讨论】:
标签: java