The following questions was found from a online-mock (sorry that I forgot where I got it)
Would anyone here kindly help to answer me...
Why line 3 is compile correctly but not line 2?!
Many thanks!!!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public class Test038
{
public static void main(
String args[])
{
new Test038().new Nested().method("first"); //1
new Test038().Nested.method("second"); //2 <-- complie error
Test038.Nested.method("third"); //3
}
static class Nested
{
static void method (String str) //4
{
System.out.println(str);
}
}
}