simpleclassdemo9.java

来自「JAVA程序设计课程中各章节的程序实例。」· Java 代码 · 共 31 行

JAVA
31
字号
/**
*A demonstration program on this keyword
* it's a simple but classic program
*2005.1.10. xhcprince
*/

public class simpleClassDemo9
{
	private int a = 66;
	
	public void show(int a)
	{
		System.out.println(this.a);	//refers the class level 'a' !
		System.out.println(a);	    //refers function level variable !
	}

	public static void main(String args[])
	{
		simpleClassDemo9 obj = new simpleClassDemo9();
	
		obj.show(3);
	}
}
/**
*The output are as follows:
* 66
* 3
*Important tips on this() and super()
* 1.Calling super() and this() should be in the first statement inside the constructor
* 2.Yuo cannot use super() and this() int the same constructor
*/

⌨️ 快捷键说明

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