I'm learning Java and I came across inner class. I'm wondering how to access the variable 'temp' present in the outer class from the inner class.
class Demo
{
private String temp = "Hello!";
class Demo2
{
private String temp = "Hello22!!";
public void show()
{
System.out.println(temp);
}
}
}
class HelloWorld
{
public static void main(String[] args)
{
Demo d = new Demo();
Demo.Demo2 d2 = d.new Demo2();
d2.show();
}
}
Here, we used the same variable name in both inner and outer classes. Is this considered as overloading?