In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is mainly about "what is the difference between Java language and C++ language", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "what is the difference between Java language and C++ language"?
Java uses C and C++ syntax format, for programmers who have studied C and C++, learning Java will probably be very easy. However, if you examine many details of the Java language, you will find that Java has removed a lot of C and C++ features and added some new features. These differences include:
O there is no longer the concept of Pointer.
This is one of the main grammatical differences between Java and CCompact +. In C and C++, the flexible use of pointers will bring great convenience to programming, but its flexibility has also become a major factor leading to program instability. With the memory management strategy of C and C++, programmers must personally track the memory they applied to the system and finally confirm and return it to the system. And when using pointers, always pay attention to whether the legal memory space is exceeded, causing problems such as Segmentation Fault or General Protection Fault.
Java provides a Reference type to replace pointers. By accessing the requested memory space through references, you can ensure that you will not access the memory space that does not belong to you. At the same time, the execution system of the program can also dynamically do memory garbage collection to reclaim the de-referenced memory space to the system. This dynamic memory allocation mechanism ensures the security of memory allocation to a certain extent by sacrificing some flexibility.
O there is no longer the concept of Function.
In the Java programming language, the function, the most important part of the structured language, is eliminated. In the concept of object-oriented programming, the data of the object is the real topic, and the method of dealing with the data of the object must be attached to the object to make sense. Therefore, the concept of function is completely unnecessary. This reinforces the object-oriented development strategy.
O structure, union, and typedef are no longer used.
In fact, in C++, you can remove the custom structure types of complex data, such as structure and union in C, because the way Class is defined can do this function. The function of typedef can also be implemented by classes. Although C++ is designed to be C-compatible, these are redundant language features that have been abandoned in the Java language.
O there is no more multiple inheritance of classes (Multiple Inheritance).
In C++, multiple inheritance is a strong function, but it is also difficult to master. Eliminating multiple inheritance reduces the functionality of the Java language, but it makes Java look more concise. At the same time, Java also provides the way of interface (Interface), which can realize the function of partial multiple inheritance. The difference from multiple inheritance is that the interface does not define the content of the class method or the data in the class.
O there are no more operator overloads (Operator Overloading).
Operator overloading is seen as a feature of C++. In C++, with operator overloading, programmers can make programs look more natural by defining existing operators themselves. However, if used improperly, the readability of the whole program will be greatly affected. At the same time, the existence of this function is not necessary, and programmers can define methods in the class to achieve the same goal.
O automatic type conversion has been cancelled.
Java is a strongly type-checking programming language. For cases such as floating-point variables assigning values to integer variables, it is allowed in the syntax of C++. At most, it only gives warnings at compile time. However, in Java, compilation cannot pass unless cast is explicitly written.
O there is no preprocessor (preprocessor) function.
By using the preprocessing instructions such as # define and # include provided in CUniverse +, powerful programmers can develop a set of macro instructions that only they can understand. From the point of view of software engineering, this is very disadvantageous to the team's development of software and the maintenance of the whole software. At the same time, the precompiled program code is different from the program code seen by the programmer. If there is something wrong with the macro instruction set, the error message generated by the compiler will not be what programmers expect, which increases the difficulty of program debugging.
O canceled the goto statement.
In C++, the goto statement is no longer recommended, and goto is retained only for compatibility with C syntax. In Java, goto statements are completely discarded. At the same time, Java expands the functions of break statements and continue statements. By using break and continue, program flow is allowed to jump in multi-tier loops.
It can be said that Java programming language is a concise and effective pure object-oriented programming language. The C++ language is not as good as Java in object-oriented features because it is compatible with C (C++ is defined as a superset of C).
At this point, I believe you have a deeper understanding of the "what is the difference between Java language and C++ language". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 257
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.