example432参数.txt
来自「java是一种面向对象程序的语言,我这里介绍了有关java课件的许多事例,它能帮」· 文本 代码 · 共 59 行
TXT
59 行
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{
public static void main( String args[ ] ){
Point p=new Point( );
int xValue=-1, yValue=-1;
System.out.println("Pass by value:");
p.getXY(xValue,yValue);
System.out.println("xValue = "+xValue+" yValue = "+yValue);
Location l=new Location( );
p.getLocation( l ); //label 2 : pass by reference
System.out.println("Pass by reference:");
System.out.println("l.x = "+l.x+" l.y = "+l.y);
}
}
运行结果为:
C:\>java ArgumentTest
Pass by value:
xValue = -1 yValue = -1
Pass by reference:
l.x = 20 l.y = 30
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?