I defined a Class Base
class Base
{
private int i;
Base(int i)
{
this.i = i;
}
}
So object of Base class can access private variable.
class BaseDemo
{
public static void main(String[] args)
{
Base objBase = new Base(10);
System.out.println(objBase.i);
}
}
But it's giving me a compiler error I has private access in Base
.
I'm confused while coding, what is wrong?