In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "introduction to the basic concepts of Java". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Java Overview:
At present, Java is mainly used in the development of middleware (middleware)-dealing with the communication technology between clients and servers. Early practice has 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 on-board computers. Java is different from other languages in that it provides platform independence when the program runs, and it can be praised in windows,solaris. Linux uses exactly the same code on other operating systems. Java syntax is similar to C++ syntax, Java programmers are easy to grasp, and Java is completely object-oriented, in which a good GC (Garbage Collector) garbage handling mechanism is proposed to prevent memory overflow.
Java's white paper presents us with 11 key features of the Java language.
(1) the syntax of Easy:Java is relatively simpler than that of C++. Another aspect is that Java can make the software run on a very small machine. The size of its support and class library support is about 40kb. To increase the basic standard library and thread-supported memory, you need to increase 125kb.
(2) distributed: Java has a very powerful routine library of TCP/IP protocol family. Java applications can access remote objects through URL through the network. Due to the emergence of servlet mechanism, Java programming is very efficient. Now many large web server support servlet.
(3) OO: object-oriented design is a programming technology that focuses on objects and their interfaces. Its object-oriented and C++ have many differences, with multiple inheritance processing and Java's original class model.
(4) robust features: Java adopts a secure pointer model that reduces the possibility of rewriting memory and data corruption.
(5) Security: Java is used to design networks and distributed systems, which brings new security problems. Java can be used to build anti-virus and anti-attack System. Facts have proved that Java has done a good job in anti-virus.
(6) Neutral architecture: Java compiles its architecture-neutral object file format that can be executed on many processors. The instruction bytecode (Javabytecode) generated by the compiler implements this feature, which 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 very good.
(8) Multithreading: the process of dealing with multithreading in Java is very simple. Java hands the multithreading implementation to the following operating system or threaded program to complete. So multithreading is one of the popular reasons for Java as a server-side development language.
(9) Applet and servlet: programs that can be executed on web pages are called Applet, and there are many browsers that support Java, while applet supports dynamic web pages, which many other languages cannot do.
Basic concepts:
The only thing that matters in 1.OOP is what the interface of the object is, just like the seller of the computer, no matter what the internal structure of the power supply is, he only cares whether he can provide electricity to you, that is, as long as he knows can or not rather than how and why. All programs are composed of certain attributes and behavior objects, the access of different objects is completed through function calls, and all communication between objects is through method calls, which greatly improves the reuse rate by encapsulating object data.
The most important idea in 2.OOP is the class, the class is the template is the blueprint, to construct an object from the class, that is, to create an instance of the class (instance)
3. Encapsulation: the implementation of combining data and behavior in a package) and hiding the data from the object consumer. The data in an object is called its instance field (instance field).
4. Get a new class called inheritance by extending a class, and all classes are extended from the Object root superclass, which is described below.
5. Three main characteristics of object
Behavior--- shows what this object can do.
State--- the reflection of an object when it imposes a method.
The distinguishing mark between identity--- and other similar behavior objects.
Each object has a unique indentity and these three influence each other.
6. The relationship between classes:
Use-a: dependencies
Has-a: aggregation relationship
Is-a: inheritance relationship-- example: class An inherits class B. at this time, class A has not only class B methods, but also its own methods. (individuality exists in commonness)
7. Construction object uses constructor: the proposal of constructor, constructor is a special method to construct object and initialize it.
Example: the constructor of the Data class is called Data
New Data ()-constructs a new object and initializes the current time.
Data happyday=new
Data ()-assign an object to a variable happyday so that the object can be used multiple times. The value returned by new is a reference that makes the variable different from the object variable.
Constructor features: constructors can have 0, one or more parameters
The constructor and the class have the same name
A class can have multiple constructors
The constructor did not return a value
Constructors are always used with the new operator.
8. Overloading: overloading occurs when multiple methods have the same name but contain different parameters. The compiler must pick which method to call.
9. Package Java allows one or more classes to be collected together into a group, called packages, to facilitate the organization of tasks. The standard Java library is divided into many packages. Java.lang java.util java,net, etc., packages are hierarchical all java packages are within the java and javax package levels.
10. Inheritance idea: allows you to build a new class based on an existing class. When you inherit an existing class, you reuse the methods and fields of that class, and you can add new methods and fields to the new class.
11. Extension class: the extension class fully reflects the inheritance relationship of is-a. The form is: class (subclass) extends (base class).
twelve。 Polymorphism: in java, object variables are polymorphic. Multiple inheritance is not supported in java.
13. Dynamic binding: a mechanism for calling 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 static final, the compiler will know exactly which method to call.
(4) when the program runs and uses dynamic binding to call a method, the virtual machine must call the version of the method that matches the actual type of the object pointed to by x.
(5) dynamic binding: an important feature that enables programs to be extensible without recompiling existing 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 specifies that one or more abstract methods must itself be defined as abstract example: public abstract string getDescripition
Every class in 17.Java is an extension of the Object class.
The equal and toString methods in the 18.object class are used to test whether an object is equal to another. ToString returns a string representing that object, and almost every class overloads the method to return a 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 with object class variables.
20. Array list: ArrayList dynamic array list, is a class library, defined in the java.uitl package, can automatically resize the array.
The getclass method in the 21.class 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 virtual machine will load all the classes it needs, and each loaded class will load the classes it needs.
22.Class classes provide powerful functional reflection for writing programs that can dynamically manipulate java code. This function is particularly useful for JavaBeans. Using reflective Java can support tools that VB programmers are used to use. Programs that can analyze class capabilities are called reflectors, and the package that provides this function in Java is called Java.lang.reflect reflection mechanism is very powerful.
1. The ability to analyze classes at run time.
two。 Explore the object of the class at run time.
3. To achieve a general array manipulation code.
4. Provides a method object.
This mechanism is mainly aimed at tools rather than applications and programs.
The most important part of the reflection mechanism is that it allows you to examine the structure of the class. The API used are:
Java.lang.reflect.Field returns a field.
Java.reflect.Method returns the method.
Java.lang.reflect.Constructor returns parameters.
Method pointer: java does not have a method pointer. Pass the address of one method to another, which can be called later, and the interface is a better solution.
23. The Interface specifies what a class should do without specifying how to do it. A class can implement one or more interface.
24. An interface is not a class, but a set of specifications for classes that meet the requirements of the interface. It takes two steps to implement an interface:
1. Declares the specified interface that the class needs to implement.
two。 Provides definitions of all methods in the interface.
Declaring a class to implement an interface requires the use of the implements keyword class actionB implements Comparable and its actionb needs to provide a 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, an important interface in Java
twenty-six。 Interface and callback. A common pattern for programming is the callback mode, in which you can specify a method on the callback object when a particular time occurs. Example: ActionListener interface snooping.
Similar API has: java.swing.JOptionPane
Java.swing.Timer
Java.awt.Tookit
twenty-seven。 The object clone:clone method is an object protection method, which means that your code cannot simply call it.
This is the end of the introduction to the basic concepts of Java. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.