如果局部变量与实例变量同名,那么如何在局部变量的作用域内引用实例变量?

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();
}
}
原文地址:https://www.cnblogs.com/ganeveryday/p/4339880.html