一个很简单得代码,大家帮忙看下
yyfsk 2003-08-23 11:41:35 class Location{
int x,y;
}
class Point{
int x,y;
Point()
{
x=20;
y=30;
}
void getXY(int xValue,int yValue)
{
xValue=x;
yValue=y;
}
void getLocation(Location lReference)
{
lReference.x=x;
lReference.y=y;
}
}
public class ArgumentTest {
/** Creates a new instance of ArgumentTest */
public static void main(String args[])
{
Point p=new Point();
System.out.println("Pass by value:");
System.out.println("xValue="+p.xValue+" yValue="+p.yValue);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~这句有问题,是出在什么问题呢?
Location l=new Location();
p.getLocation(l);
System.out.println("Pass by reference:");
System.out.println("xValue="+l.x+" yValue="+l.y);
}
}
希望高手解释一下,多谢了。