Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the Java basic method

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to use the basic method of Java". In the daily operation, I believe that many people have doubts about how to use the basic method of Java. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts about how to use the basic method of Java. Next, please follow the editor to study!

# method overloading (Overload)

Method overloading performs the same function, and multiple methods have the same method name, but their parameters are different.

Method overloading mainly depends on the distinction of parameter type and quantity.

The method overload should return the same value type.

# Construction method

The construction method is a special method, and the main characteristics of the construction are:

1 the method name is the same as the current class name.

2 if there is no constructor with parameters defined in the class, the compiler creates a default constructor, so there is at least one constructor for a class.

3 the constructor does not return a value, nor does it have a void

4 Construction method can only be used in combination with new

Student S1 = new student ()

Note: but if we create a constructor with parameters in the class, the compiler will not create the default parameterless constructor

Class TestClass {public TestClass (String testArg) {/ / TODO Auto-generated constructor stub}} error: TestClass TestClass = new TestClass ()

# overloading of constructor

Public class User {private String name; private int age; private Date birthday; public User (String ncent int a date b) {name = n; age = a; birthday = b;} public User (String ncent int a) {name = n; age = a } public User (String n) {name = n;}} at this point, the study on "how to use the basic methods of Java" is over. I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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: 0

*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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report