Learning 30 basic concepts in the J2SE process

xiaoxiao2021-03-06  56

Learning 30 basic concepts in the J2SE process

(smile)

2004-7-13 10:30:07

Preface: In the process of learning Java, master the basic concepts to our learning, whether it is J2SE, J2EE, J2ME, J2SE is the foundation of Java, so it is necessary to summarize the basic concepts. So everyone better understands the essence of Java in the future learning process, here I summarize 30 basic concepts.

Java Overview: Currently Java is mainly used in the development of middleware --- Processing communication technology between clients, early practice proves that Java is not suitable for the development of PC applications, and its development has gradually become developed The development of handheld devices, Internet information stations, and car computer. Java is different from other languages ​​that provide the stand-independence of the platform when the program is running, which is highly identical to the exact same code on Windows, Solaris, Linux other operating systems. Java The syntax is similar to the C syntax, and the C / C programmer is easy to master, and Java is a completely thorough object-oriented, which proposes a good Garbage Collector waste handling mechanism to prevent memory overflow. Java's white paper We propose 11 key features of the Java language. (1) Easy: Java syntax is relatively simple than C , and another aspect is Java to run software on a small machine, the basic explanation of its support The size of approximately 40KB, increasing basic standard libraries and thread supported memory needs to increase 125KB. (2) Distributed: Java has a strong routine library with very powerful TCP / IP protocols, Java applications can pass through the URL Network to access remote objects, due to the appearance of the servlet mechanism, making Java programming very efficient, now many large web server supports servlet. (3) oo: object-oriented design is to focus on objects and objects A programming technology. Its object-oriented and C have a lot of differences in the processing of multiple inheritance and the original model of Java. (4) Running characteristics: Java takes a safety pointer model to reduce rewrite memory and data crash Possible (5) security: Java is used to design a network and distribution system, which brings new security issues, and Java can be used to build antivirus and anti-attack SYSTEM. Facts prove that Java is compared Good. (6) Neutral Architecture: Java Compiles It Generates Ended Target File Formats in Multi-Processing, and Javabytecode generated by the compiler is implemented on many processors. This byte code can be Interpretation execution on the machine. (7) Portability: Java has strict regulations on the size and algorithms of basic data structure types, so the portability is very good. (8) Multi-thread: Java processing multithreaded process is very simple, Java handles multi-thread implementation to the bottom operating system or thread program. So 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 web page is applet, you need to support Java A lot of browsers, and applet Support for dynamic web pages, this is a lot of other languages. Basic concept: 1. The only relationship in OOP is what the object's interface is, just like a computer sales, it is, he only Whether the relationship can provide you with electricity, that is, just know that CAN or NOT is not how and why. All programs are composed of certain attributes and behavior objects, different object access through function calls, and between All exchanges are called by way of ways. By increasing the reuse rate through the package object data. 2. The most important idea inoo is class, the class is a blueprint, constructed from the class, which is created. An instance of this class (Instance) 3. Package: Binding data and behavior in a package) and hides the data of the data, the data in an object calls him instance field (Instance Field) 4. By expanding a class to get a new class called inheritance, and all classes are extended by Object root superclass, and the root super class will be introduced. 5. 3 main features of the object Behavior- - Describe what this object can do. State --- Reflection of the object when the object is applied. Identity - distinguished with other similar behavior objects. Each object has a unique INDENTITY and the 3 The relationship between classes: USE-A: Dependence HAS-A: Aggregation Relationship IS-A: Inheritance Relationship - Example: A Class A inherits Class B, at this time, Class A is not only a method B, There is also its own method. (Personality exists in a commonality) 7. Construction object uses a constructor: The presentator is proposed, the constructor is a special method, constructing the object and initializes it. Example: DATA class constructor Data

New Data () --- Constructs a new object and initializes the current time.

Data happyday = new data () - The value assigns an object to a variable happyday, so that the object can be used multiple times, and the value of the variable and the object variable is different. NEW is one. Quote. Constructor Features: The constructor can have 0, one or more parameters

The constructor and the same name have the same name

A class can have multiple constructors constructors without returning value constructors always used together with the New operator.

8. Overload: When multiple methods have the same name and contain different parameters, it is overloaded. The compiler must select which method of calling.

9. Package Java allows one or more classes to become a group, called packets to facilitate organizational tasks, standard Java libraries are many packages .java.lang java.util Java, NET, etc. It is all Java packages in the Java and Javax package.

10. Inherited Thoughts: Allow new classes on the basis of existing classes, when you inherit an existing class, then you have multiplexed the methods and fields of this class, and you can add it in the new class. New methods and fields.

11. Extended class: Extended class fully reflects the inheritance relationship of IS-A. Form is: Class (subclass) Extends.

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

13. Dynamic Binding: Mechanism of calling an object method.

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

(2) The compiler checks the parameter type called by the method.

(3) Static binding: If the method type is the Priavte Static Final compiler, which method will be accurately known.

(4) When a program is running and using a dynamic binding to call a method, then the virtual machine must call the method version of the actual type of object to which X points to the X.

(5) Dynamic binding: It is very important to make the program become scalable without need to recompile the filed code.

14.Final Class: In order to prevent some people from derived new categories from your class, this type is not expandable.

15. Dynamic calls have taken longer than static calls,

16. Abstract class: The class specified by one or more abstract methods must be defined as Abstract

Example: Public Abstract String GetDescripition

17. Each class in Java is expanded from the Object class.

18. 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 overloads the method to return the correct representation of the current state.

(TSTRING method is a very important method)

19. Universal Programming: All values ​​of any class type can be replaced with the object class variable.

20. Array List: ArrayList dynamic array list, is a class library, defined in the java.uitl package, automatically adjusts the size of the array.

21. The getClass method in the Class class Object class returns an instance of the CKASS type. When the program is started, the class containing the main method will be loaded. The virtual machine should load all the classes he need, and each loaded class is loaded. the type.

22. Class class provides powerful functional reflection for programming programming that can dynamically manipulate Java code. This feature is especially useful for JavaBeans, using reflection Java to support VB programmers used to use tools. Campaign to analyze the ability to call reflectors The package of this feature in Java is very powerful in java.lang.Reflect reflex mechanism.

1) The ability to analyze class at runtime.

2). Objects in the runtime.

3). Implement universal array manipulation code.

4). Provide method objects.

This mechanism is primarily targeted by tools rather than applications and procedures.

The most important part of the reflective mechanism is to allow you to check the structure of the class. The API used by:

Java.lang.Reflect.field Returns the field. Java.Reflect.Method Returns the method. Java.lang.reflect.constructor Returns the parameters.

Method pointer: Java has no method pointer, passing the address of a method to another, can call it later, and the interface is a better solution.

23. Interface indicates what the class does not specify how to do it, and a class can implement one or more interface.

24. The interface is not a class, but a set of specifications for classes that meet the interface requirements.

If you need to implement an interface, you need 2 steps:

1). The specified interface that needs to be implemented. 2). Provide definitions of all the methods in the interface.

Declare a class to implement an interface. You need to use the imports keyword Class Actionb IMPLEMENTS Comparable. It is necessary to provide a CompareTo method. The interface is not a class, and an interface cannot be instantiated with a New.

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

26. Interface and callback. Programming a common mode is a callback mode. In this mode you can specify a method on the callback object when a specific time occurs. Example: ActionListener interface monitors. Similar APIs are: java.swing. JOPTIONPANE JAVA.SWING.TIMER JAVA.AWT.Tookit

27. Object Clone: ​​Clone method is Object a protection method, which means that your code cannot be simply call it.

28. Internal Class: Definition of an internal class is a class defined in another internal

The reason is: 1. An internal class object can access the implementation of the object that created it, including private data 2. For other classes in the same package, the internal class can hide. 3. Anonymous internal classes can be convenient Define the callback. 4. Use the internal class to be very convenient to write event drivers.

29. Proxy: 1. Specify the interface to require all the code 2.Object class definition (TSTRING Equals)

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

Author / Source: Greatqsh

转载请注明原文地址:https://www.9cbs.com/read-114670.html

New Post(0)