Static methods can call static methods and static variables, but also non-static methods and non-static variables.
Public class test {public test () {}; public test (int I) {This. N = I;} public static int M = 5; Public int n = 10; Public void fun1 () {system. out. println ("non-static method fun1");} public static void fun2 () {system. out. println ("static method fun2");} // test "static methods can only call static variables and static methods". What does it mean: public static void main (string [] ARGs) {// No error will be reported when a static method is called // fun2 (); // when a static variable is called, system will not be reported. out. println (m); // The non-static method fun1 () // fun1 () cannot be referenced from the static context; // The non-static method cannot be referenced from the Static Context Non-static variable N // system. out. println (n); // you can call the non-static method constructor in the new object of the static method. The following code can be correctly executed no matter whether the default constructor is used or not. Therefore, "in the compilation stage, the compiler does not check the operations related to specific objects and objects in static methods ". In this way, a solution is provided to access non-static methods and non-static attributes in static methods. // Test T = new test (8); // T. fun2 (); // T. fun1 (); // system. out. println (T. m); // system. out. println (T. n );}}