Learn Java's 30 basic concepts __java

Source: Internet
Author: User
Learn 30 Basic concepts of Java

In the process of learning Java, mastering the basic concepts of our learning is very important both j2se,j2ee,j2me, J2SE is the basis of Java, so it is necessary to do a summary of the basic concepts, so that everyone in the future learning process to better understand the essence of Java, Here I have summed up 30 basic concepts.

Java Overview:

At present, Java is mainly used in middleware development (middleware)---Processing client-server communication technology, early practice proved that Java is not suitable for the development of PC applications, its development has gradually become in the development of handheld devices, Internet information stations, and on-board computer development. The difference between Java and other languages is that the program runs with the independence of the platform, and the Windows,solaris,linux can use exactly the same code on 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 simpler than C + +, and another aspect is that Java enables software to run on very small machines, with the base explaining that its support for the class library is about 40KB, and increasing the basic standard library and thread-supported memory needs to be increased by 125kb.

(2) Distributed: Java with a very powerful TCP/IP protocol Family example threading, Java applications can pass through the network URL to access the remote objects, because of the emergence of the servlet mechanism, so that Java programming is very efficient, now many large web The server supports the servlet.

(3) OO: object-oriented design is a programming technique that focuses on the interfaces of objects and objects. Its object-oriented and C + + are many different in the processing of multiple inheritance and Java's original class model.

(4) Robustness: Java takes a safe pointer model that reduces the likelihood of overwriting memory and data crashes.

(5) Security: Java is used to design networks and distribution systems, which creates new security issues that Java can use to build antivirus and anti-attack system. It turns out that Java is doing a better job of anti-virus.

(6) Neutral architecture: Java compilation its generation architecture-neutral target file format can be executed on many processors, and compiler-generated instruction bytecode (Javabytecode) implements this feature, which can be interpreted on any machine.

(7) Portability: Java in the basic data structure type size and algorithm are strict rules so portability is good.

(8) Multithreading: Java processing multithreading process is very simple, Java to the implementation of multithreading to the bottom of the operating system or thread program completed. So multithreading is one of the popular reasons for Java as a server-side development language

(9) Applets and servlet: programs that can be executed on a Web page are called applets, require a lot of Java-enabled browsers, and applets support Dynamic Web pages that many other languages cannot.

Basic concepts:

The only relationship in 1.OOP is what the object's interface is, like a computer vendor, she doesn't care what the internal structure of the power supply is, he only has to be able to supply you with electricity, that is, if you know can or not instead of how and why. All programs are made up of certain attributes and behavior objects, The access of different objects is accomplished by function call, all communication between objects is through method call, and the reuse rate is greatly improved by encapsulating object data.

The most important idea in 2.OOP is class, a template is a blueprint, an object is constructed from a class, an instance of this class is created (instance)

3. Encapsulation: It is the combination of data and behavior in a package and the user of the object to hide the implementation of the data, the data in one object is called his instance field (instance field)

4. By extending a class to get 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 characteristics of the object
Behavior---Explain what this object can do.
State---The object's reflection when the object exerts a method.
Identity---Distinguishing mark from other similar behavior objects.
Each object has a unique indentity and these 3 interact with each other.

6. Relationships between classes:
USE-A: Dependencies
Has-a: Aggregation relations
Is-a: Inheritance Relationship--Example: A class inherits Class B, at which point a class not only has the B class method, but also its own method. (Personality exists in commonness)

7. Construction objects use constructors: The constructor is proposed, which is a special method of constructing and initializing the object.
Example: The constructor for the data class is called data
The new Data ()---Constructs a fresh object and initializes the current time.
Data happyday=new
The Data ()---assigns an object to a variable happyday so that the object can be used more than once, where the variable is declared differently from the object variable. The value returned by new is a reference.
Constructor features: The constructor can have 0, one or more parameters
Constructors and classes have the same name
A class can have more than one constructor
Constructor has no return value
Constructors are always used with the new operator.

8. Overloading: Overloading occurs when multiple methods have the same name and contain different parameters. The compiler must pick which method to invoke.

9. Package (Package) Java allows one or more classes to be collected together into 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 etc, The package is layered and all Java packages are within the Java and Javax package hierarchy.

10. Inheritance thought: Allows you to build new classes on the basis of existing classes, and when you inherit an existing class, you reuse the methods and fields of the class, and you can add new methods and fields to the new class.

11. Extended class: The extended class fully embodies the is-a inheritance relationship. The form is: Class (subclass) extends (base class).

12. Polymorphism: In Java, object variables are polymorphic. Multiple inheritance is not supported in Java.

13. Dynamic binding: The mechanism by which the object method is invoked.
(1) The compiler examines the type and method name of the object declaration.
(2) The compiler checks the parameter type of the method invocation.
(3) Static binding: If the method type is priavte 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 a program extensible without the need to recompile the stored code.

14.final class: This class is not extensible to prevent others from deriving new classes from your class.

15. A dynamic call takes longer than a static call,

16. Abstract class: A class that prescribes one or more abstract methods must itself be defined as an 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. (ToString method is a very important method)

19. Universal Programming: All values of any class type can be substituted with variables of object class.

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 included in the main method when the program starts is loaded, the virtual confidential loads all the classes he needs, and each loaded class loads the class it needs.

The 22.class class provides powerful reflective functionality for writing programs that dynamically manipulate Java code, a feature that is particularly useful for JavaBeans, using reflection Java to Support tools that VB programmers are accustomed to using. The program that can analyze class ability is called reflector, Java provides this functionality in the package called Java.lang.reflect reflection mechanism is very powerful.
1. The ability to analyze classes at run time.
2. Probe the object of the class at run time.
3. Implement common array manipulation code.
4. Provide method object.
This mechanism is mainly aimed at the tool rather than 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 return method.
Java.lang.reflect.Constructor return parameters.
Method pointer: Java does not have a method pointer, passing the address of one method to another, which can be called later, and the interface is a better solution.

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

24. An interface is not a class, but rather a set of specifications for classes that meet the requirements of an interface. It takes 2 steps to implement an interface:
1. Declares the specified interface that the class needs to implement.
2. Provide definitions 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 needs to provide a CompareTo method, the interface is not a class, and an interface cannot be instantiated with 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 pattern is the callback pattern, in which you can specify a method to callback the object when a particular time occurs. Example: ActionListener interface Monitor.
Similar APIs are: Java.swing.JOptionPane
Java.swing.Timer
Java.awt.Tookit

27. The object Clone:clone method is an object protection method, which means that your code cannot simply invoke it.

28. Internal class: The definition of an inner class is a class defined within another
The reason is: 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, the inner class can be hidden.
3. Anonymous inner classes can be easily defined as callbacks.
4. The use of internal classes makes it easy to write event drivers.

29. Proxy: 1. Specify all methods that the interface requires for all code 2.object classes to be defined (toString equals)

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

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.