class TestClass
{
int val=5;
public static void main(
String args[])
{
if( val > 4 )
{ System.out.println( "Test A" );
}
else if( val > 9 )
{ System.out.println( "Test B" );
}
else System.out.println( "Test C" );
}
}
I had thought the code would compile clearly ,but the compiler complain that :Can't make a static reference to nonstatic variable val in class TestClass.would you please give me a reason for the result.