Java Basic Learning Summary (with eclipse some common operations)

Source: Internet
Author: User

First, this keyword
1. Use this to call this class member variable and member function
2. Call the constructor with this

Second, static variable statics keyword

1. Contains static member variable, member function. Can be called directly using the class name.
2, static member variable only one copy.
3. This cannot be used in static functions.
4. The main function of static code blocks is to assign values to static member variables.

Iii. succession of extend
1. Inheritance is used to reduce duplication of code.
2. Use Super to call the parent class constructor method.
3. In the constructor of the subclass, the constructor of the parent class must be called. Compiler default plus super ();
4. Inheritance can only inherit member functions, member variables. The constructor of the parent class cannot be inherited. So with the Super keyword.
5, the function of the replication (override), also known as overwrite or rewrite. Among the two classes that have a parent-child relationship, the parent and child classes each have a function that is identical in definition (return value, function name, and argument list).

Transition upward (assigns the object of the subclass to the parent class reference)
2. A reference can invoke those members (variables and functions), depending on the type of the reference.
3. Which method is called by a reference, depending on the object to which the reference is directed.

Transformation down (a reference to a subclass that assigns the object of the parent class)
1, downward transformation, the premise is to transform the parent class reference, and then assign the object of the parent class to the child class reference.

Iv. Abstract Functions
Abstract functions are functions that do not have a function body.
Classes defined with abstract are referred to as abstract classes.
1. Abstract classes are not capable of generating objects. is used to be inherited.
2. If a class contains abstract functions, then the class must be declared as an abstract class.
3, if there is no abstract function in a class, then this class can also be declared as an abstract class.
4. Abstract classes can also have constructors that can be called by Super.

Five, package name (packages)
1, compile the need to use the-d parameter, the function of the parameter is to generate the corresponding folder according to the package name.
2. The full name of a class should be "package name" + "." + "class name".
Naming conventions for package names:
1. Require that all letters of the package name be lowercase.

2. Package name in general, is your domain name inverted write;


Vi. access Rights

1. Public can modify classes, member variables, and member functions.
There are no restrictions, the same package, or the classes in different packages are free to access.
2, private can modify member variables and member functions.
Can only be used in this class.
3, default (do not write the permission modifier, is the default permission) can be decorated classes, member variables and member functions.
In the same package, you have free access.
If the subclass and parent are not in the same package, the subclass can inherit the member variables and member functions of the default permission in the parent class room, but cannot be used because of insufficient permissions.
4, protected permissions first have the same function as default, but this permission can only modify member variables and member functions.
Protected are generally used to inherit relationships between classes, parent classes, and subclasses. Subclasses are protected member variables and member functions that can be used with the parent class.
5. Permission level: public > Protected > Default > Private

VII. basic syntax for interfaces
1. Using interface definition
2. The methods in the interface are abstract methods
3. The methods in the interface are public permissions
4. Implement the interface using the Implements keyword
5. A class can implement multiple interfaces
6. A single interface can inherit multiple interfaces
Simple Factory mode: The interface uses an upward transformation, and all the objects that need new are encapsulated into a class.

Viii. Exceptions in Java
Exception: The normal flow of instructions has been interrupted
Check Exception:java the virtual machine requires code that is likely to have an exception to be thrown.
Uncheck Exception:java the virtual machine does not know the code that will appear the exception.


X. Common operations of Eclipse

1. Push the class method to the parent class method



2, several methods to reconstruct the extraction



3. Modify the signature of the function method



4. Repeating statement re-construction method



5. Reconstruct the name of auto-change class


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Java Basic Learning Summary (with eclipse some common operations)

Related Article

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.