12 major features of the entry-level Java language

Source: Internet
Author: User

1. Java is simple

Java is very similar to C ++, but it is much simpler. AdvancedProgramming LanguageOf all the features, not absolutely required, have been deleted. For example, Java does not include operator overload, title file, preprocessing, pointer operation, structure, union, multi-dimensional array, template, and implicit type conversion. If you know something about C, C ++, or Pascal, you will soon be able to master Java. Here is a simple javahelloworldProgram:

The following is a reference clip:
Public class hellointernet
{
Public static void main (string argv [])
{
System. Out. println ("Hello Internet! ");
}
}

2. Java is object-oriented

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

Just like any object-oriented language, JavaCodeIt is also organized by class. Each class defines a set of methods that define object behavior. A class can inherit the behavior of another class. At the root level of the class, it is usually a class object.

JAVA supports a single inheritance class hierarchy. This means that each class can only inherit one class at a time. Some languages allow multi-inheritance, but this may cause confusion and make the language unnecessary to complicate. For example, it is hard to imagine that an object will inherit the behavior of two completely different classes.

Java also supports abstract interfaces. This allows the programmer to define the interface method first, without having to determine the implementation of the method immediately. A class can implement 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 an idlj compiler. That is to say, Java can be used to build a Distributed Object System in the CORBA object system. In view of the fact that many computer systems use the IDL Interface and the CORBA object system, this compatibility is important.

3. Java is static

In a Java program, the types of objects (numbers, characters, arrays, etc.) must be defined. This helps programmers quickly discover problems because type errors can be detected during program compilation.

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

4. Java is compiled.

When running a Java program, it is first compiled into byte code. Byte Code is very similar to machine commands, so Java programs are very efficient. However, the byte code is not specific to a specific machine, so Java programs can be executed on many different computers without recompilation.

The Java source program is compiled into a class file, which is equivalent to the byte code of the program. In a Java class file, all references to methods and instance variables are performed by name and identified during the first code execution. This makes the code more generic and less susceptible to modifications, but still highly efficient.

5. Java is Architecture Neutral

The Java language is the same for every computer. For example, simple types are unchanged: integers are always 32 bits and long integers are always 64 bits. The strange thing is that the trendy programming languages such as C and C ++ are not like this. Since these languages are so free to define, each compiler and development environment is different, which makes program porting a nasty problem. Java program porting is very easy, and does not need to be re-compiled.

6. Java is sound

The Java program cannot cause a computer crash. The Java System carefully detects every access to the memory and confirms that it is valid without causing any problems.

However, even Java programs may have errors. If something unexpected occurs, the program will not crash and discard the exception. The program will find and handle such exceptions.

Traditional programs can access all the computer's memory. The program may (unconsciously) modify any value in the memory, which may cause problems. Java programs can only access those parts in the memory that they are allowed to access. Therefore, Java programs cannot modify unmodifiable values.

7. Java is small

Because Java is designed to run on a small computer, as a programming language, its system is relatively small. It can effectively run on a PC with more than 4 mb ram. The Java translator only occupies several hundred kb. This translator is reliable for Java platform independence and portability.

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

8. Java is multi-threaded.

Java programs can execute more than one thread. For example, it can complete a time-consuming computing in a thread, while other threads interact with users. Therefore, you do not have to stop working and wait for the Java program to complete time-consuming computing.

Programming in a multi-threaded environment is usually difficult, because many things may appear at the same time. However, Java provides easy-to-use synchronization features to make programming more convenient.

Java threads are usually mapped to actual operating system threads as long as the underlying operating system supports this ing. Therefore, applications written in Java can be called "MP hot ". That is to say, if they run on a multi-processor machine, they will be even more remarkable.

9. Java can collect useless storage units

Programmers who use C and C ++ to write software must carefully track the memory blocks used. When a block is no longer used, they must let the program release it for reuse. In large projects, this may be difficult and often becomes the root cause of errors and insufficient memory.

In the case of Java, programmers do not have to worry about memory management. The Java System has a built-in program called "useless unit Collector", which scans the memory and automatically releases memory blocks 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 slower than C. This is acceptable for most applications. In the near future, code generators will be available, making Java programs almost as fast as those written in C or C ++.

11. Java is secure

Java programs do not have pointers, and byte code programs like this are strongly typed. Therefore, it may verify Java programs before execution. The verified Java program ensures that it does not break through any restrictions of the Java language and can be safely executed. Java byte code verification is used by Web browsers to ensure that applets do not contain viruses.

12. Java is scalable.

Java programs can be connected to existing libraries written in other languages. The Java data structure is very similar to the data structure type of C, which is quite convenient. The biggest problem is that there are only a few multi-threaded libraries.

Java programs can declare that some methods are internal, and then map these internal methods into functions defined by the software library to dynamically link them to virtual machines.

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.