Can we use instance/non-static variable directly from static area?

class Variable1
{
int x=10;
public static void main(String[] alt)
{
System.out.println(x);
}
}
/*
Output:- CE[non-static variable x cannot be referenced from a static context]
Explanation:- We cannot access instance variable directly from static area.
If we want to access instance variable from static area then we
can access by using object reference. But from instance area we can
access instance variable directly.
*/

0 comments: