public class ThisExample {
int a = 10; //instance variable
void display()
{
int a = 200; //Local variable
System.out.println("Local Variable = " + a);
System.out.println("İnstance variable = " + this.a);
}
public static void main(String[] args) {
ThisExample obj = new ThisExample();
obj.display();
}
}
//Output:
Local Variable = 200
İnstance variable = 10
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter