6th Day of Java Learning

Source: Internet
Author: User

today, the main thing is to learn about static variables, mainly for the same member variables of multiple objects, to save space. It is loaded as the class is loaded and can be either a method or an object. Called directly from the class name. For example, the main method is that it can be called directly.

The Main method is static
Public: Maximum Permissions
Static: Do not create object calls
void: Return value does not make sense to the JVM
Main: is a common name.
String[] args: Can receive data, flexibility of the provider

It is important to note that the static method does not have the This keyword, because static load is loaded with the load, this is with the creation of the object exists. Static variables: Can be called by object name, or by class name. Member variable: can only be called by object name

Then it is the production of instructions. Format

/**

* This is a tool class to clean up the cache for a movie

* @author XX

* @version V. 1.1

*/

Write in front of the class you want. Note that the comments in the class are mainly @param after adding parameters and @return and returning values. After you finish writing? The command box uses the javadoc-d directory-author-version class name. Java, when you're done, open the directory to find index.html open the Help document to help develop, but we still have to have a JDK_API document to search for unfamiliar classes encountered in learning. The specific use is as follows

Open the Help document
2: Click Show, find index, see Input box
3: Know who you're looking for? Take scanner Example
4: Enter scanner in the input box and return
5: Look at the bag
The classes under the Java.lang package do not need to be imported, and all others need to be imported.

to import:
Java.util.Scanner
6: Just take a look at the explanation and description of the class, and don't forget to look at the version of the class
7: See Structure of the class
member Variable field summary
Constructor method Construction Method Summary
Member Method Method summary
8: Learning how to construct
A: Create an object with a construction method
B: No constructor method members may be static
9: See Member Methods
A: Left
static: If static, can be called through the class name
return value type: What is returned, you receive with what.
B: Right
look at the method name: method names don't write wrong
parameter list: What people want, you give what, others want a few, you give a few.

And then the inheritance, in C + + talked about mainly to see if there is anything different. Format. Class subclass name extends the parent class name. The details I noticed are: 1java only support single inheritance does not support multiple inheritance, this is not the same. Zzzzz ... The various permissions on private and public are not said. 2 to illustrate the way that a subclass's method accesses a variable's lookup order: The local scope of the subclass method is found, and is used. in the subclass of the member scope to find, there is the use. in the member scope of the parent class, it is used.

6th Day of Java Learning

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.