public class Sample
{
private int a=1; //实例变量

public void b()
{
int a=2; //局部变量
System.out.println("局部变量:a="+a);
System.out.println("实例变量:a="+this.a);//局部变量的作用域内引用实例变量:this.变量名
}
public static void main(String[] args)
{
new Sample().b();
}
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-01
  • 2022-12-23
  • 2021-08-22
  • 2022-12-23
  • 2021-12-05
  • 2021-12-05
猜你喜欢
  • 2021-09-06
  • 2021-11-24
  • 2022-12-23
  • 2022-03-06
  • 2022-12-23
  • 2021-06-09
  • 2022-02-16
相关资源
相似解决方案