What are the main features of the Java language?

Source: Internet
Author: User

1. Simple

Java was originally designed as a language for integrated control of household appliances, so it must be simple and straightforward. The simplicity of the Java language is mainly reflected in the following three aspects:

1) Java's style is similar to C + +, so C + + programmers are very familiar with it. In a sense, the Java language is a variant of the C and C + + languages, so C + + programmers can quickly master Java programming techniques.

2) Java has discarded the areas of C + + that are prone to program errors, such as pointers and memory management.

3) Java provides a rich library of classes.

2. Object-oriented

Object-oriented can be said to be the most important feature of Java. The Java language is designed to be completely object-oriented, and it does not support process-oriented programming techniques like the C language. Java supports code inheritance and reuse in both static and dynamic styles. Java is similar to small talk in terms of object-oriented features, but other features, especially those that apply to distributed computing environments, go far beyond small talk.

3. Distributed

Java includes a sub-library that supports TCP/IP-based protocols such as HTTP and FTP. As a result, Java applications can open and Access objects on the network with URLs that are almost identical to accessing the local file system. The dynamic content provided for the distributed environment, especially the Internet, is undoubtedly a very ambitious task, but Java's syntactic nature makes it easy to achieve this goal.

4. Robust

Java is committed to checking the program's errors at compile and run time. Type checking helps to check out many errors that occurred early in development. Java self-manipulating memory reduces the likelihood of memory errors. Java also implements a true array, avoiding the possibility of overwriting data. These feature features greatly shorten the cycle of developing Java applications. Java provides null pointer detection for array bounds detection exception exit byte code check.

5. Structural neutrality

In addition, in order to build Java as a whole of the network, Java compiles its programs into a structure-neutral intermediate file format. This intermediate code can be executed by a machine with a Java operating system. Now, the Java operating system has Solaris2.4 (SPARC), Win32 Systems (WINDOWS95 and WindowsNT) and so on. Java source programs are compiled into a high-level machine-independent Byte-code format language, This language is designed to run on a virtual machine and is implemented by a machine-related run debugger.

6. Security

Java security can be guaranteed in two ways. On the one hand, in the Java language, C + + functions like pointers and freeing memory are removed to avoid illegal memory operations. On the other hand, when Java is used to create a browser, the language features are combined with the functionality provided by the browser itself to make it more secure. The Java language is tested many times before it is executed on your machine. It is checked by code, checks the format of the code snippet, detects pointer manipulation, whether the object is manipulated excessively, and attempts to change the type of an object.

7. Portable

This phrase has always been the spiritual indicator of Java programmers, and one of the reasons why Java can be loved by programmers, the biggest contributor is the technology of the JVM. Most compiler-generated target code can only run on one CPU (such as Intel's x86 series), even those that support multiple CPUs can not produce target code that is suitable for multiple CPUs at the same time. If you need to run the same program on three CPUs (such as x86, SPARC, and MIPS), you must compile three times.

But the Java compiler is different. The Java compiler produces the target code (J-CODE) for a non-existent Cpu--java virtual machine (Java virtual machines), not a real CPU. The Java virtual function masks the difference between different CPUs, enabling J-code to run on any machine with a Java virtual machine.

The concept of virtual machines is not unique to Ava: The University of California introduced the concept of the Pascal virtual machine a few years ago; The Perl scripts that are widely used in UNIX servers are also used to generate machine-independent intermediate code for execution. But the special thing about a Java virtual machine designed for Internet applications is that it can produce a secure target code that is not virus-protected. It is because of the special requirements of security features of the Internet that the JVM can be quickly accepted by people. Today's mainstream operating systems, such as OS/2, MacOS, and windows95/nt, have been or are quickly providing support for J-code.

As a virtual Cpu,java, the virtual machine is independent of the source code. Not only can we generate J-code in the Java language, we can also use ADA95 to generate them. In fact, there are j-code compilers for a number of provenance codes, including Basic, Lisp, and forth. Once the source code has been converted to J-code, the Java Virtual machine is able to execute without distinguishing which provenance code it was generated from. The result of this is CPU portability. The advantage of compiling the source program into J-code is that it can run on a variety of machines, and the disadvantage is that it runs faster than native code.

Architecture-independent features enable Java applications to run on any computer system equipped with a Java interpreter and a running environment, making it a good foundation for Java application Software portability. But that's just not enough. If the basic data type design relies on a specific implementation, it will also cause great inconvenience to the porting of the program. For example, in Windows3.1, integers are 16bits, integers in Windows95 are 32bits, integers in DECAlpha are 64bits, and 32bits is in Intel486. By defining platform-independent basic data types and their operations, Java data is consistent across any hardware platform. The basic data types of the Java language and how they are represented are as follows: Byte8-bit twos complement Short16-bit twos complement Int32-bit twos complement Long64-bit twos complement float32-bitieee754 floating point double32-bitieee754 Floating-point Char16-bitunicode characters in any Java interpreter, data types are implemented in accordance with the above criteria. Because almost all CPUs currently in use can support the above data types, complement operations in 8~64-bit integer format, and single/double precision floating-point operations. The Java compiler itself is written in the Java language. The Java computing system is based on the limitations of POSIX portability and is written in ansic language. There is also nothing in the Java language specification that is "relevant to a specific implementation."

8. Explanation of

The Java Interpreter (running system) can run the target Code directive directly. The linker usually has less resources than the compiler needs, so programmers can spend more time creating the source program.

9. High Performance

If the interpreter is slow, Java can translate the target code directly into machine instructions at run time. Sun uses a direct interpreter to invoke 300,000 processes in a second. The speed of translating the target code is no different from the performance of C + +.

10. Multithreading

Multithreading makes it possible to perform multiple small tasks simultaneously in one program. Threads--sometimes called small processes--are small, independent processes that come out of a large process. Because of the multithreading technology implemented by Java, it is more key than C and C + +. The greater benefit of multithreading is better interaction performance and real-time control performance. Of course, real-time control performance also depends on the system itself (Unix,windows,macintosh, etc.), in the development of ease and performance is better than single-threaded. Anyone who has used the current browser feels that waiting for a picture to be tuned is a very disturbing thing. In Java, you can use a single thread to tune a picture, and you have access to other information in the HTML without waiting for it.

11. Dynamic

The dynamic characteristic of Java is the development of its object-oriented design method. It allows the program to dynamically load the classes needed to run the process, which is not possible with the C + + language for object-oriented programming. In C + + programming, whenever an instance variable or a member function is added to a class, all subclasses that reference the class must recompile, or the program will crash. Java has taken steps to address this problem in the following ways. Instead of compiling references to instance variables and member functions as numeric references, the Java compiler passes the symbolic reference information to the interpreter in bytecode, and the interpreter converts the symbolic reference information to a numeric offset after the dynamic connection class is completed. In this way, a memory-generated object is not determined during compilation, but is deferred until the runtime is determined by the interpreter. In this way, the variables and methods in the class are updated without affecting the existing code. The lookup and conversion process of this symbolic information is performed only once when a new name appears, and the code can be executed at full speed when the bytecode is interpreted. The benefit of determining a reference at run time is that you can use a class that has been updated without worrying about affecting the original code. If a program connects to a class in another system on the network, the owner of the class can also be free to update the class without crashing any programs that reference the class. Java also simplifies the method of using an upgraded or entirely new protocol. If your system runs a Java program and encounters a program that does not know how to handle it, it doesn't matter, Java can automatically download the function program you need. Four. Similarities and differences with C and C + + Java provides all the functionality of a powerful language, but with little ambiguity. C + + security is not good, but C and C + + is still accepted by everyone, so Java design into C + + form, so that everyone is easy to learn. Java removes many of the features of the C + + language, makes Java's language functionality very refined, and adds a useful feature that Java removes from the following C and C + + features and features: pointer arithmetic structure typedefs# Define need to free the definition of the global variables of memory This feature is a very easy place to cause errors.

Unicode

Java uses Unicode as its standard character, and this feature allows Java programs to be written and executed on platforms of different languages. Simply put, you can use the variable in the program, the category name in Chinese to represent the <, and when your program is ported to other language platforms, it can be performed normally. Java is also the only language in all computer languages that is inherently Unicode-used.

What are the main features of the Java language?

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.