The Java language contrasts several advantages of the C + + language and its own key features

Source: Internet
Author: User

The reason why this blog is written is not to compare the Java language and C + + language in the end which is inferior, but from the language itself on the comparison summary program coding design differences. Because of the limited level, some content may be too partial, please correct and discuss.

The Java language is well designed to draw on the C + + language and is a completely "object-oriented" programming language. The syntax of the Java language is very similar to the structure syntax of the C + + language, making it very easy for C + + program apes to learn java.

The biggest advantage of the Java language is that "wirte once,run Everywhere" means "write once, run everywhere". The Java language has added some new features to C + +: 1) provides GC, automatic memory management, program Ape No need to allocate, free memory in the program, generally no longer worry about memory allocation error, 2) no longer use pointers, but other methods to compensate; 3) compared to C + +, Java eliminates multiple inheritance, which makes the inheritance of classes concise; 4) avoids confusion between assignment statements and logical statements, and eliminates the automatic conversion of other and Boolean values, which effectively reduces some run-time errors.

As for the key features of the Java language, this is an easy question to ask in the interview process, which illustrates your understanding of this programming language from a macro perspective. The Java language is a very good programming language, with many effective features, the main is the following several.

  simple and effective . The Java language is a concise "object-oriented" language that is more rigorous and concise than C + +, without all the incomprehensible, confusing features of the C + + language, such as pointers, structs, operator overloads, virtual base classes, and so on.

  Object-oriented . The Java language is a fully object-oriented language that does not support process-oriented programming techniques such as C-language, which is the most important language feature of the Java language. The Java language encapsulates data and operations on the data in a single class, and provides classes, interfaces, and inheritance, and the Java Class (class) supports only single inheritance (c + + supports multiple inheritance), interfaces (interface) support multiple inheritance, and the implementation (implements) mechanism between classes and interfaces. Java is similar to Smalltalk on object-oriented, but better than Smalltalk in other ways.

  portability . Java applications can run on any computer system equipped with a Java parser and a running environment, which makes Java applications a good base for portability.

  explanatory type . The Java language is an interpreted language, and Java programs are inefficient and slow to perform in contrast to C + +, but it is because Java interprets Java code by running the Java interpreter on different platforms, thus realizing "Wirte Once,run Everywhere "cross-platform objectives. There's got to be some. On the other hand, as machine performance improves, explaining technology improvements (like instant compilation, just in time), users may not care about this performance difference.

  suitable for distributed computing . Java is a language suitable for the development of Web applications, written in the Java Language Socket communication program can be accessed as a local file system through a URL to access remote objects, you can implement public Gateway Interface (CGI) script development, you can also apply Java applets (applets), Java Server Page (Java server page,jsp), servlet and other methods for network application development.

The Java language contrasts several advantages of the C + + language and its own key features

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.