Java Learning---3. Object oriented

Source: Internet
Author: User

1. Method overloads: Overload (), same as method names, but with different parameters. Construction methods can also be overloaded.

In-memory layouts

2.this Keyword: This is a variable, is a reference to the current object, this is pointing to himself.

You can handle the case where the name of a member variable and parameter in a method.

3.static keyword: A common variable for a class, initialized for the first time, with only one copy. Allocated in the data area.

No matter the new object instance, it has only one copy. Any object instance can access a static object and access the same piece of memory. (string constants are also in the data area)

The static method of the static declaration does not pass a reference to the object to it when the method is called, so the non-static member is inaccessible in the static method.

4. Package

Resolves a naming conflict problem with classes, providing a tired multi-class namespace.

To define a class:

Package COM.BJSXT;

public class cat{}

Reference class:

Import Com.bjsxt.Cat;

The parent directory of the topmost package of the class file must be located under Classpath. Executes a class to write all-inclusive names.

Package your own class into a jar package: Navigate to the top-level file of the package: JAR-CVF Xx.jar * *

* * Pack all the files into a jar package

Java Learning---3. Object oriented

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.