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

📄 test.java

📁 java实验报告书:其中包括实验代码以及说明等
💻 JAVA
字号:
class Rectangle
{
	protected int width;
	protected int height;
	
	//下面是类Rectangle的三个构造方法
	
	public Rectangle()
	{		//此方法无参数,缺省地给出长和宽
		width=20;height=30;
	}
	public Rectangle(int w,int h)
	{		//此方法由参数给出长和宽
		width=w;height=h;
	}
	public Rectangle(Rectangle r)
	{		//此方法给出另一个Rectangle作参数
		width=r.width();
		height=r.height();
	}
	public int width()
	{
		return width;
	}
	public int height()
 	{
		return height;
	}
}
class Test
{
	public static void main(String args[])
	{
		Rectangle R1=new Rectangle();
		//R1.Rectangle();
		int w1=R1.width();
		int h1=R1.height();
		System.out.println("width="+w1+"height="+h1);
		Rectangle R2=new Rectangle(200,300);
		//R2.Rectangle(200,300);
		int w2=R2.width();
		int h2=R2.height();
		System.out.println("width="+w2+"height="+h2);
		Rectangle R3=new Rectangle(R1);
		//R3.Rectangle(R1);
		int w3=R3.width();
		int h3=R3.height();
		System.out.println("width="+w3+"height="+h3);
  }
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -