In Java, one method is used to call another method. In java, another method is called.
In the same class:
For static methods, other static or non-static methods can be called directly.
For non-static methods, other non-static methods can be called directly. However, other static methods can be called only through objects.
Static methods cannot be overwritten by non-static methods.
Public class Test2 {public static void s1 () {System. out. println ("s1");} public void say1 () {System. out. println ("say1");} public void say () {s1 (); say1 (); // call say1 method} public static void main (String [] args) {s1 (); Test2 t = new Test2 (); t. say ();}}
Jpg
For different classes, whether the called method is non-static or static, if the called method is:
Static Method, you can call both the class name and object (but it is not recommended to use the object method because it is a non-static call method)
A non-static method can be called only through an object.
Public class CallTest2 {public static void s () {System. out. println ("s1");} public void say () {Test2 t2 = new Test2 (); // call the method t2.say () in Test; t2.s1 (); test2.s1 ();} public static void main (String [] args) {CallTest2 t = new CallTest2 (); t. say ();}}
In the above Java example, calling another method is to share all the content with you. I hope to give you a reference, and I hope you can provide more support to the customer's house.