In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "what are the calls of java methods?". In the operation of actual cases, many people will encounter this dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
There are mainly several kinds of method calls in JAVA: 1. Non-static methods are methods without static modification. Calls to non-static methods are called through an object, as shown below.
Object name. Method ()
Eg:
Public class InvokeMethod {public static void main (String [] args) {InvokeMethod in = new InvokeMethod (); in.t1 ();} public void T1 () {System.out.printfln ("T1");}}
two。 Calling a static method is a method decorated with static. The call to a static method is called through the class name, as shown below:
Class name. Method ()
Eg:
Public class InvokeMethod {public static void main (String [] args) {InvokeMethod.t2 ();} public static void T2 () {System.out.println ("static T2....");}}
3. The call between methods and methods is mainly about how to call other methods within one method. (1) calling other methods inside static methods if in this class, static methods can call static methods directly, not only in main methods, but also in custom static methods. If it is a non-static method in this class, it must be called through an object.
Public class InvokeMethod {public static void main (String [] args) {T2 ();} public static void T2 () {System.out.println ("static T2...");} public static void T1 () {/ / static method call non-static method calls / / InvokeMethod in = new InvokeMethod (); / / in.t2 (); T2 () System.out.println ("static T1");}}
If you are not in one class, static methods call static methods in other classes, and you must pass the
Class name. Static method ()
If a static method calls a non-static method of another class in a different class, you need to import the package in that class and call it by creating an object.
(2) Internal calls to non-static methods if in this class, non-static methods can directly call static methods and non-static methods. In different classes, when non-static methods call static methods of other classes, you need to import packages in this class, and you need to call them through class names. When non-static methods call non-static methods of other classes, you need to import packages in this class and call them by creating objects.
This is the end of the content of "what are the invocations of java methods?" Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 269
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.