30 concepts to be mastered by beginners in Java

Source: Internet
Author: User

The only relationship in 1.OOP is what the object's interface is, just like a computer vendor. Regardless of the internal structure of the power supply, he will only be able to provide you with electricity, that is, as long as you know can or not rather than how and why. All the programs are composed of a certain property and the behavior of the object, the access of different objects through the function call to complete, all communication between objects is through the method call, through the encapsulation object data, greatly improve the reuse rate.

The most important idea in 2.OOP is the class, the class is the template is the blueprint, constructs an object from the class, namely creates an instance of this class (instance).

3. Encapsulation: is to combine data and behavior in a package, and to hide the data for the object user implementation process, the data in an object called his instance field (instance field).

4. By extending a class to obtain a new class called Inheritance (Inheritance), all classes are extended by the object root superclass, and the root superclass is described below.

5.3 main features of an object

Ehavior---Explain what this object can do.

Tate---The object's reflection when the object is applied to the method.

Dentity---A distinguishing token from other similar behavior objects.

Each object has a unique indentity and these 3 are affected by each other.

6. Relationships between classes:

USE-A: Dependencies

Has-a: Aggregation Relationship

Is-a: Inheritance Relationship--Example: Class A inherits Class B, at which point a class has not only the method of Class B, but also its own method. (Personality exists in commonness)

7. Construct objects using constructors: Constructors are proposed, constructors are a special method of constructing objects and initializing them.

Example: The constructor of the data class is called data

The new Data ()---Constructs an object and initializes the current time.

Data happyday=new data ()---assigns an object to a variable happyday, so that the object can be used more than once, where the variable to be declared differs from the object variable. The value returned by new is a reference.

Constructor features: Constructors can have 0, one or more parameters; Constructors and classes have the same name; A class can have more than one constructor; The constructor does not return a value; The constructor is always used with the new operator.
8. Overloading: Overloads occur when multiple methods have the same name and have different parameters. The compiler must pick out which method to call.

9. Package Java allows one or more classes to be gathered together as a group, called a package, to facilitate the organization of tasks, and the standard Java library is divided into many packages. Java.lang Java.util java,net and so on, packages are hierarchical and all Java packages are within the Java and Javax package hierarchy.

10. The idea of inheritance: Allow new classes to be built on top of existing classes, and when you inherit a class that already exists, you reuse the methods and fields of the class, and you can add new methods and fields to the new class.

11. Extension classes: The extension class fully embodies the inheritance of is-a. The form is: Class (subclass) extends (base class).

12. Polymorphism: In Java, the object variable is polymorphic. Multiple inheritance is not supported in Java.

13. Dynamic binding: A mechanism for invoking object methods.

(1) The compiler checks the type and method name of the object declaration.

(2) The compiler checks the parameter type of the method call.

(3) Static binding: If the method type is priavte the static final compiler will know exactly which method to call.

(4) When a program runs and uses dynamic binding to invoke a method, the virtual machine must call the method version that matches the actual type of the object that X points to.

(5) Dynamic binding: It is an important feature that makes the program extensible without the need to recompile the saved code.

14.final class: To prevent others from deriving new classes from your class, this class is not extensible.

15. Dynamic calls take longer than static calls.

16. Abstract class: A class that prescribes one or more abstract methods must itself be defined as abstract.

Example: Public abstract string Getdescripition

Each of the classes in 17.Java is extended from the object class.

The equal and ToString methods in the 18.object class.

Equal is used to test whether an object is equal to another object.

ToString Returns a String representing the object, and almost every class overloads the method to return the correct representation of the current state.

(The ToString method is a very important method)

19. General programming: All values of any class type can be substituted with the object class variable.

20. Array list: ArrayList dynamic array list, is a class library, defined in the JAVA.UITL package, can automatically adjust the array of the Colonel

The GetClass method in the 21.class class object class returns an instance of the Ckass type, the class that is contained in the main method is loaded when the program starts, the virtual machines load all the classes that he needs, and each loaded class loads the classes it needs.

The 22.class class provides powerful functional reflection for writing programs that dynamically manipulate Java code, a feature that is particularly useful for JavaBeans, and uses reflective Java to support tools that are used by VB programmers. A program that can analyze class capabilities is called a reflector, and the package called Java.lang.reflect, which provides this functionality in Java, is very powerful.

A. Ability to parse classes at run time.

B. Object that explores the class at run time.

C. Implement universal array manipulation code.

D. Provide the method object.

And this mechanism is mainly for the tool and not the application and the program.

The most important part of the reflection mechanism is allowing you to examine the structure of the class. The APIs used are:

Java.lang.reflect.Field returns the field.

Java.reflect.Method returns the method.

Java.lang.reflect.Constructor returns the parameter.

Method Pointers: Java has no method pointers, passes the address of one method to another, can call it later, and the interface is a better solution.

23. The interface (Interface) describes what the class should do without specifying how to do it, and a class can implement one or more Interface.

24. An interface is not a class, but a set of specifications for a class that conforms to the interface requirements. If implementing an interface requires 2 steps:

A. Declare the specified interface that the class needs to implement.

B. Provide a definition of all the methods in the interface.

Declaring a class to implement an interface requires using the Implements Keyword Class ACTIONB implements comparable its actionb needs to provide a CompareTo method, the interface is not a class, and you cannot instantiate an interface with new.

25. A class has only one superclass, but a class can implement multiple interfaces. An important interface in Java: cloneable

26. Interfaces and callbacks. A common pattern of programming is the callback pattern, in which you can specify a method on the callback object when a specific time occurs.

Example: ActionListener interface monitoring.

Similar APIs are:

Java.swing.JOptionPane
Java.swing.Timer
Java.awt.Tookit

27. The object Clone:clone method is an object-protected method, which means that your code cannot simply call it.

28. Inner class: The definition of an inner class is a class that is defined within another. The reasons are:

A. An object of an inner class can access the implementation of the object that created it, including private data.

B. For other classes in the same package, inner classes can be hidden.

C. Anonymous inner classes can easily define callbacks.

D. It is very convenient to write event drivers using internal classes.

29. Agent Class (proxy):

A. Specifying the interface requires all code

All methods defined by the B.object class (ToString equals)

30. Data type: Java is the language of the emphasis type, each variable must first declare that it is a type, Java has a total of 8 basic types. 4 types are integer, 2 are floating point types, one is character type, is used in Unicode encoding characters, Boolean type.

30 concepts to be mastered by beginners in Java

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.