Joke Collection Website - News headlines - What language is java?

What language is java?

Java is an object-oriented programming language. It not only absorbs the various advantages of the C language, but also abandons the concepts such as multiple inheritance and pointers that are difficult to understand in C. Therefore, the Java language is powerful, simple and easy to use. Use two features. As a representative of static object-oriented programming languages, Java language perfectly implements object-oriented theory and allows programmers to perform complex programming with an elegant way of thinking.

Java is a strongly typed language, which allows extended compile-time checking for potential type mismatch problems. Java requires explicit method declarations and does not support C-style implicit declarations.

Java can write desktop applications, Web applications, distributed systems and embedded system applications, etc.

Characteristics of Java:

Java has the characteristics of simplicity, object-oriented, distributed, robustness, security, platform independence and portability, multi-threading, and dynamics; Let's introduce it in detail below:

1. Simplicity

Java seems to be designed very much like C, but in order to make the language small and easy to be familiar with, the designers put the C language into Many available features that are rarely used by average programmers have been removed. For example, Java does not support the go to statement and instead provides break and continue statements as well as exception handling. Java also eliminates C's operator overload (overload) and multiple inheritance features, and does not use the main file, eliminating the need for preprocessors. Because Java has no structures, arrays and strings are objects, so no pointers are needed. Java can automatically handle object references and indirect references and realize automatic collection of useless units, so that users do not have to worry about storage management issues and can spend more time and energy on research and development.

2. Object-oriented

The Java language provides object-oriented features such as classes, interfaces and inheritance. For simplicity, it only supports single inheritance between classes, but supports interfaces. Multiple inheritance, and supports the implementation mechanism between classes and interfaces (the keyword is implements). The Java language fully supports dynamic binding, while the C language only uses dynamic binding for virtual functions. In short, the Java language is a pure object-oriented programming language.

3. Distribution

Java is designed to support applications on the network. It is a distributed language. Java not only supports various levels of network connections, but also supports reliable stream network connections with the Socket class, so users can generate distributed clients and servers.

The network becomes a distribution vehicle for software applications. Java programs only need to be written once and run anywhere.

4. Compilation and interpretability

The Java compiler generates byte-code (byte-code) instead of usual machine code. Java bytecode provides an architecture-neutral object file format, and the code is designed to efficiently deliver programs to multiple platforms. Java programs can run on any system that implements a Java interpreter and run-time system.

In an interpreted environment, the standard "linking" phase of program development largely disappears. If there is a linking stage in Java, it is just the process of loading new classes into the environment. It is an incremental and lightweight process. Therefore, Java supports rapid prototyping and easy experimentation, which will lead to rapid program development. This is an elegant development process in stark contrast to the traditional, time-consuming "compile, link, and test."

5. Robustness

Java was originally used as a language for writing consumer home electronics software, so it is designed to write highly reliable and robust software. Java eliminates certain programming errors, making it fairly easy to write reliable software in it.

Java's strong typing mechanism, exception handling, automatic garbage collection, etc. are important guarantees for the robustness of Java programs. Discarding pointers is a smart choice for Java.

Java's security checking mechanism makes Java more robust.

6. Security

Java's storage allocation model is one of its main ways to defend against malicious code. Java has no pointers, so programmers cannot get behind the scenes and fake pointers to memory. More importantly, the Java compiler does not handle storage arrangement decisions, so the programmer cannot guess the actual storage arrangement of the class by looking at the declaration. Storage references in compiled Java code determine the actual storage address at runtime by the Java interpreter.

The Java runtime system uses a bytecode verification process to ensure that code loaded onto the network does not violate any Java language restrictions. Part of this security mechanism includes how classes are loaded from the Internet. For example, loaded classes are placed in separate namespaces rather than local classes, preventing a malicious applet from replacing standard Java classes with its own versions.

7. Portability

Java makes language declarations independent of implementation aspects. For example, Java explicitly states the size and operation behavior of each basic data type (these data types are described by Java syntax).

The Java environment itself is portable to new hardware platforms and operating systems. The Java compiler is also written in Java, while the Java runtime system is written in ANSIC language.

8. High performance

Java is a language that is compiled first and then interpreted, so it is not as fast as a fully compiled language. But there are situations where performance is critical. To support these situations, Java designers created a "just-in-time" compiler, which translates Java bytecode into machine code for a specific CPU (central processing unit) at runtime, as well. That is to achieve full compilation.

The Java bytecode format was designed with the needs of these "just-in-time" compilers in mind, so the process of generating machine code is quite simple, and it can produce pretty good code.

9. Multi-threading

In the Java language, a thread is a special object that must be created by the Thread class or its descendants (grandchildren). There are usually two methods to create a thread:

1) Use a constructor subclass with the type Thread(Runnable) to wrap an object that implements the Runnable interface into a thread,

2) Derive a subclass from the Thread class and override the run method. The object created using this subclass is a thread. It is worth noting that the Thread class has implemented the Runnable interface, so any thread has its run method, and the run method contains the code to be run by the thread. The activity of a thread is controlled by a set of methods. The Java language supports the simultaneous execution of multiple threads and provides a synchronization mechanism between multiple threads (the keyword is synchronized).

10. Dynamics

One of the design goals of the Java language is to adapt to dynamically changing environments. The classes required by Java programs can be dynamically loaded into the running environment, or the required classes can be loaded through the network. This also facilitates software upgrades. In addition, classes in Java have a run-time representation and can perform run-time type checking.

11. Platform independence

Java programs (files with the suffix java) are compiled into an architecture-neutral bytecode format (files with the suffix class) on the Java platform , which can then be run on any system that implements this Java platform. This approach is suitable for heterogeneous network environments and software distribution.