12 major features of the Java language

Source: Internet
Author: User

1. Java is simple

Java is very similar to C + +, but it is much simpler. All the features of the high-level programming language, not absolutely necessary, have been deleted. For example, Java does not have operator overloading, header files, preprocessing, pointer operations, structs, unions, multidimensional arrays, templates, and implicit type transformations. If you know a little C, C + + or Pascal, you'll soon be driving java. Here is a simple Javahelloworld program:

Publicclasshellointernet

{

Publicstaticvoidmain (stringargv[])

{

System.out.println ("helloin-ternet!")

}

}

2, Java is Object-oriented

Java is an object-oriented programming language. In addition to simple types, such as numbers and Boolean operators, most of Java is an object.

Like any object-oriented language, Java code is organized by class. Each class defines a set of methods that specify the behavior of the object. A class can inherit the behavior of another class. At the root level of a class, it is usually a class object.

Java supports single-inheritance class hierarchies. This means that each class can inherit only one other class at a time. Some languages allow multiple inheritance, but this can cause confusion and unnecessarily complicate the language. For example, it is difficult to imagine that an object inherits the behavior of two completely different classes.

Java also supports the interface of the Digest class. This allows the programmer to define the method of the interface without having to rush to determine the implementation of the method immediately. A class can execute multiple interfaces, which has many advantages of true multi-inheritance. An object can also implement any number of interfaces. The Java interface is very similar to the IDL interface. It is easy to build IDLJ compilers. This means that Java can be used for CORBA object systems to build distributed object systems. This compatibility is important given the use of IDL interfaces and CORBA object systems in many computer systems.

3. Java is a static type

In a Java program, you must define the types of objects used (numbers, characters, arrays, and so on). This helps the programmer quickly discover the problem because the type error can be detected when the program compiles.

However, objects in the Java system also have dynamic types. It is often possible to require an object to be a dynamic type, so programs written by programmers can do different things for different types of objects.

4. Java is a compiled type

When running a Java program, it is first compiled into a byte code. The byte code is very similar to machine instructions, so the Java program is very efficient. However, byte code is not specific to a particular machine, so Java programs can be executed on many different computers without recompiling.

The Java source program is compiled into a class file, which is equivalent to the program's byte code representation. In a Java class file, all references to methods and instance variables are made by name and resolved the first time the code is executed. This makes the code more generic, less susceptible to modification, and still more efficient.

5, Java is architecture-neutral

The Java language is the same for each type of computer. For example, simple types are immutable: integers are always 32 bits, and long integers are always 64 bits. Surprisingly, trendy programming languages such as C and C + + are not. Because these language definitions are so free, each compiler and development environment is different, which makes porting the program a nuisance. Porting Java programs is easy and does not require recompilation.

The 6.Java is a sound

Java programs cannot cause a computer crash. The Java system carefully detects every access to memory, confirms that it is legitimate, and does not cause any problems.

However, even Java programs may have errors. If something unexpected happens, the program does not crash and discards the exception. The procedure will identify such exceptions and deal with them.

A traditional program can access all of the computer's memory. The program may (unconsciously) modify any value in memory, which can cause problems. Java programs can access only those parts of memory that are allowed to access them, so Java programs cannot modify values that are not intended to be modified.

7, Java is small

Since Java is designed to run on a small computer, its system is relatively small as a programming language. It can effectively run on a PC with more than 4MB RAM. The Java translator occupies only hundreds of KB. This translator is reliable for the platform independence and portability of Java.

Because Java is small, it is ideal for small-memory computers, such as Java-based PCs, and televisions, ovens, telephones, and home computers.

8, Java is multi-threaded

Java programs can execute more than one thread. For example, it can perform a time-consuming calculation in one thread, while other threads interact with the user. So the user doesn't have to stop working and wait for the Java program to finish the time-consuming calculation.

Programming in a multithreaded environment is often difficult because many things can occur at the same time. However, Java provides easy-to-use synchronization features that make programming easier.

Java threads are typically mapped as actual operating system threads, as long as the underlying operating system supports this mapping. Therefore, applications written in Java can be said to be "MP hot." This means that if they are running on multiprocessor machines, they will be more extraordinary.

9. Java is a collection of useless storage units

Programmers who write software in C and C + + must carefully track the memory blocks used. When a block is no longer in use, they must let the program release it so that it can be reused. In large projects, this can be difficult and often a source of errors and memory shortages.

In the case of Java, programmers don't have to worry about memory management. The Java system has a built-in program called a "useless unit collector" that scans memory and automatically frees blocks of memory that are no longer in use.

10. Java is fast

Java is much more effective than a typical scripting language, but it is 20 times times slower than C. This is acceptable for most applications. In the near future, code generators are available, which will make Java programs nearly as fast as programs written in C or C + +.

11. Java is secure

Java programs do not have pointers, and byte code programs like this are strong on types, so it is possible to validate Java programs before executing them. The validated Java program is guaranteed to not break any limitations of the Java language and can be executed safely. Java byte code validation is used by Web browsers to ensure that applets do not contain viruses.

12. Java is extensible

Java programs can be connected to existing libraries written in other languages. This is quite handy because Java data structures are very similar to the types of data structures in C. The biggest problem is that there are few existing multi-threaded libraries.

Java programs can declare that some methods are internal, and then map these internal methods to the functionality defined by the Software library to dynamically link to the virtual machine.

12 major features of the Java language

Related Article

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.