In the course of learning Java, it is very important to master the basic concepts of Java. j2se is the basis of Java, therefore, it is necessary to summarize the basic concepts so that you can better understand the essence of Java in the future. I have summarized 30 Basic concepts here.
Java Overview: currently, Java is mainly used for middleware development (middleware)-communication technology for processing clients between servers. Early practices have proved that Java is not suitable for PC application development, its development has gradually become the development of handheld devices, internet information stations, and on-board computers. different from other languages, Java provides platform independence during program running, which means identical code can be used on Windows, Solaris, and Linux operating systems. java syntax is similar to C ++ syntax. c ++/C programmers can easily master it, and Java is completely object-oriented, A good GC (Garbage Collector) mechanism is proposed to prevent memory overflow. the Java White Paper presents 11 key features of the Java language. (1) Easy: Java syntax is relatively simple than C ++, and Java enables software to run on very small machines, the basic explanation is that the size supported by the class library is about 40 kb. To increase the size of the basic standard library and thread-supported memory, you need to increase by 1. 25kb. (2) distributed: Java has a very powerful library of routines for TCP/IP protocol families. Java applications can access remote objects through the network through URLs. Due to the emergence of servlet mechanisms, java programming is very efficient. Many large Web servers now support servlet. (3) OO: Object-oriented Design is a programming technology that focuses on the interfaces of objects and objects. its object-oriented model is different from that of C ++ in terms of Multi-inheritance processing and the original class model of Java. (4) Robustness: Java adopts a safe pointer model to reduce the possibility of overwrite memory and data crash. (5) Security: Java is used to design network and distributed systems, which brings about new security problems. Java can be used to build anti-virus and anti-attack systems. it turns out that Java is better at anti-virus.
(6) Neutral architecture: Java compiles and generates an architecture. The neutral target file format can be executed on many processors. The javabytecode generated by the compiler implements this feature, this bytecode can be interpreted and executed on any machine. (7) Portability: Java has strict rules on the size and algorithms of basic data structure types, so the portability is good. (8) multithreading: The process of processing multithreading in Java is very simple. in Java, the implementation of Multithreading is handed over to the operating system or thread program. therefore, multithreading is one of the popular reasons for Java as a server-side development language (9) Applet and Servlet: The program that can be executed on the webpage is called applet. There are many browsers that need to support Java, applet supports dynamic web pages, which cannot be implemented in many other languages. basic concepts: 1. the only link in OOP is what the interface of the object is. Just like a computer vendor, no matter what the internal structure of the power supply is, it only depends on whether it can provide electricity to you, that is, as long as you know can or not rather than how and why. all programs are composed of certain attributes and behavior objects. Different objects are accessed through function calls, And all communication between objects is done through method calls, by encapsulating object data, the reuse rate is greatly improved. 2. the most important idea in OOP is the class. A class is a blueprint and an object is constructed from the class, that is, an instance of the class is created. 3. encapsulation: the process of combining data and behavior in a package) and hiding data from the object user. The data in an object is called its instance field. 4. by extending a class to obtain a new class called inheritance, all classes are extended by the object root superclass. The root superclass are described below. 5. three main features of an object
Behavior --- describe what this object can do.
State --- reflection of an object when the object applies a method.
Identity --- the identifier for distinguishing from other similar behavior objects.
Each object has a unique indentity, which affects each other.
6. Relationships between classes:
Use-A: dependency
Has-A: Aggregation relationship
Is-A: inheritance relationship -- for example, Class A inherits class B. In this case, Class A not only has class B methods, but also its own methods. (personality exists in commonalities) 7. constructor: constructor is a special method used to construct and initialize an object.
For example, the data constructor is called data.
New data () --- construct a new object and initialize the current time.
Data happyday = new
Data () --- assign an object to a variable happyday so that the object can be used multiple times. The variables and object variables to be declared here are different. the value returned by new is a reference.
Constructor features: constructor can have 0, one or more parameters
The constructor and class have the same name.
A class can have multiple Constructors
The constructor does not return values.
The constructor is always used with the new operator. 8. overload: when multiple methods have the same name and contain different parameters, the overload occurs. the compiler must select the method to call. 9. package Java allows one or more classes to be collected together into a group called a package to facilitate task organization. The standard Java library is divided into many packages. java. lang Java. util Java, net, etc. The packages are all hierarchical Java packages within the Java and javax package layers. 10. inheritance: allows you to create new classes based on existing classes. When you inherit an existing class, you reuse the methods and fields of this class, you can also add new methods and fields in the new class. 11. extension class: the extension class fully reflects the inheritance relationship of is-. format: Class (subclass) extends (base class ). 12. polymorphism: in Java, object variables are polymorphism. java does not support multiple inheritance.
13. dynamic binding: Call the object method mechanism.
(1) The Compiler checks the object declaration type and method name.
(2) The Compiler checks the parameter types of method calls.
(3) Static binding: if the method type is priavte static final, the compiler will know exactly which method to call.
(4) When a program is running and dynamic binding is used to call a method, the virtual machine must call the method version that matches the actual type of the object pointed to by X.
(5) dynamic binding: it is an important feature that enables programs to be scalable without the need to re-compile existing code. 14. final class: to prevent others from generating new classes from your class, this class cannot be expanded. 15. dynamic call takes longer than static call, 16. abstract class: specifies that the class of one or more abstract methods must be defined as abstract. Example: public abstract string getdescripition 17. every class in Java is extended from the object class. 18. the equal and tostring methods in the object class. EQUAL is used to test whether an object is equal to another object. tostring returns a string representing the object. Almost every class will reload 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 replaced by variables of the object class. 20. array list: arraylist dynamic array list, which is a class library defined in Java. in the uitl package, the array size can be adjusted automatically. 21. the getclass method in the class object class returns an instance of the ckass type. When the program starts, the class contained in the main method will be loaded, and the VM will load all the classes it needs, each loaded class must load the class it needs. 22. the class provides powerful functional reflection for programming programs that can dynamically manipulate Java code. This function is especially useful for JavaBeans. Using Reflection Java can support tools that VB programmers are used. programs capable of analyzing class capabilities are called reflectors. Java provides this function package called Java. lang. the reflect reflection mechanism is very powerful.
1. Ability to analyze classes at runtime.
2. Check the object of the class at runtime.
3. Implement Generic Array code.
4. Provides method objects.
This mechanism mainly targets tool providers rather than applications and programs.
The most important part of the reflection mechanism is to allow you to check the structure of the class. The APIs used include:
Java. Lang. Reflect. Field returned field.
Java. Reflect. Method return method.
Java. Lang. Reflect. constructor return parameters.
Method pointer: Java does not have a method pointer. If you pass the method address to another method, you can call it later, and the interface is a better solution.
23. an interface describes what a class should do without specifying how to do it. A class can implement one or more interfaces. 24. an interface is not a class, but a set of specifications for classes that meet the interface requirements. two steps are required to implement an interface:
1. Declare the specified interface to be implemented by the class.
2. Define all methods in the interface.
To declare a class to implement an interface, you must use the implements keyword class Actionb implements comparable. Its Actionb must provide the compareto method. The interface is not a class and cannot be instantiated with new. 25. A class has only one superclass, but a class can implement multiple interfaces. cloneable 26 is an important interface in Java. interface and callback. A common programming mode is the callback mode. In this mode, you can specify the method on the callback object when a specific time occurs. example: actionlistener interface listener.
Similar APIs include Java. Swing. joptionpane.
Java. Swing. Timer
Java. AWT. Tookit 27. Object clone: the clone method is a protection method for objects, which means that your code cannot simply call it.
28. Internal class: the definition of an internal class is defined in another internal class
The reason is: 1. An internal class object can access the implementation of the object that creates it, including private data
2. For other classes in the same package, internal classes can be hidden.
3. Anonymous internal classes can easily define callbacks.
4. you can easily write event drivers using internal classes. 29. proxy: 1. specify all codes for the interface. all methods defined by the object class (tostring equals) 30. data Type: Java is a language that emphasizes the type. Each variable must first declare that it is of the type. Java has a total of eight basic types. four types are Integer type, two types are floating point type, and one is character type. They are used for Unicode encoding characters and Boolean characters.