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

📄 extendstest.java

📁 java程序设计 清华出版社 孙燮华老师编写的程序源代码
💻 JAVA
字号:
//extendsTest.java
class c1{
  int x=25;
  private int y;

  protected void print1(){
    System.out.println("This is protected method. It can be extended.");
  }
	
  private void print2(){
    System.out.println("This is private method.");
  }
}

class extendsTest extends c1{
  public static void main(String[] args){
  	c1 p = new c1();
	System.out.println("p.x = "+p.x);
	//System.out.println("p.y = "+p.y);//错误! y has private access in c1
	p.print1();
	//p.print2();                   //错误! pirnt2() has private access in c1
  }
}

⌨️ 快捷键说明

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