Java Overview:
Currently Java is mainly used in the development of middleware (middleware)---processing client-to-server communication technology, early practice proved that Java is not suitable for the development of PC applications, and its development has gradually become in the development of handheld devices, Internet Information stations, and vehicle computer development. Java differs from other languages in that the program runs with the platform's independence, and commends the ability to use the exact same code on windows,solaris,linux other operating systems. Java syntax is similar to C + + syntax, C++/C programmers are easy to master, and Java is completely object-oriented, which presents a good GC (garbage Collector) garbage disposal mechanism to prevent memory overflow.
The Java White Paper presents 11 key features of the Java language.
(1) Easy:java's syntax is relatively simple compared to C + +, and another aspect is that Java enables software to run on very small machines, and the basic explanation for its support of the class library is about 40KB, increasing the basic standard library and thread-supported memory needs by 125KB.
(2) Distributed: Java with a very powerful TCP/IP protocol Family example libraries, Java applications can pass through the network URL to access remote objects, due to the advent of the servlet mechanism to make Java programming very efficient, now many large web The servlet is supported by the server.
(3) OO: Object-oriented design is a programming technique that focuses on the interface of objects and objects. Its object-oriented and C + + have many differences in the processing with multiple inheritance and the original class model of Java.
(4) Robust features: Java has adopted a secure pointer model that can reduce the potential for rewriting memory and data crashes.
(5) Security: Java is designed to design networks and distributed systems, which introduces new security issues that Java can use to build anti-virus and anti-attack system. It turns out that Java is doing better on antivirus.
(6) Neutral architecture: Java compiles its generation architecture-neutral target file format can be executed on a number of processors, the compiler-generated instruction bytecode (Javabytecode) implements this feature, and this bytecode can be interpreted and executed on any machine.
(7) Portability: Java has strict rules on the size and algorithm of basic data structure types, so portability is good.
(8) Multithreading: Java process of multithreading is very simple, Java to the implementation of multi-threaded to the bottom of the operating system or threading program. So multithreading is one of the popular reasons for Java as a server-side development language.
(9) Applets and Servlets: programs that can be executed on a Web page are called applets, many browsers need to support Java, and applets support Dynamic Web pages, which many other languages cannot.
The only relationship in 1.OOP is what the object's interface is, 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, just know can or not and do not. All programs are made up of certain attributes and behavior objects, The access of different objects is accomplished by function call, and all communication between objects is through method call, and the reuse rate is greatly improved by the encapsulation object data.
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
Behavior---Explain what this object can do.
State---The object's reflection when the object imposes a method.
Identity---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 has no return value
Constructors are 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 packages, 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 size of the array.
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.
1. Ability to parse classes at run time.
2. Probe the object of the class at run time.
3. Implement universal array manipulation code.
4. 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:
1. Declare the specified interface that the class needs to implement.
2. Provide a definition of all the methods in the interface.
Declaring a class implementing an interface requires the use of the Implements keyword
Class ACTIONB implements comparable its actionb need to provide a CompareTo method, the interface is not a class, 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:
1. An object of an inner class can access the implementation of the object that created it, including private data.
2. For other classes in the same package, inner classes can be hidden.
3. Anonymous inner classes can easily define callbacks.
4. It is very convenient to write event drivers using an internal class.
29. Agent Class (proxy):
1. Specify that the interface requires all code
All methods defined by the 2.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.
Java beginners should know the concept (GO)