⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 example432

📁 几个简单的java学习代码
💻
字号:

  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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -