(1) Java has a garbage collection mechanism, and of course there is no C ++ destructor. However, the controllability is a little worse than that of C ++, and it does not mean that there will be no memory leakage with garbage collection. Because of mutual reference and other reasons, the object's life cycle may be too long, and garbage collection may fail. For the collection of object memory, I personally think it should be something that programmers can grasp. C ++ can use intelligent pointers such as auto_ptr and shared_ptr to perform automatic analysis. The premise is that you must be familiar with their implementation mechanisms and application scenarios (2) all objects in Java are allocated to the stack. in Java, there are only handles, that is, references, and no pointers. What are the benefits of doing so? A) no pointer. No sizeof in Java, no *. Let's take a look at the following statements. B) Avoid temporary objects. All objects in Java are represented by handles, function parameters are passed, and results are returned in the form of handles. This avoids the common local pointer local reference issues in C ++, object parameter copy assignment, slicing, and other issues, improving efficiency and reliability. String A = new string ("123"); // Java codestd: string * A = new string ("123"); // C ++ code (c) in Java, the inclusion relationship can only be represented by a handle. (3) Java is a single inheritance system, and C ++ can have multiple inheritance. Java can use interfaces to implement multiple inheritance. Let's talk about the object class in Java. The clone method can also be implemented in C ++. For more information, see <more effective tive C ++> equals method. Because objects in Java can only be represented by handles, it does not have the ability to overload the C ++ operator, so this is an equivalent object. In C ++, We can overload the "=" operator to determine the equivalent object. The Finalize method is similar to the destructor, but it must not be used as an destructor. It depends on the hashcode method of the garbage collection mechanism, STL does not have hashmap or hashtable, but Java. util, so ..... The rest are methods that meet the thread and synchronization requirements. They are not comparable with C ++ (3) arrays in Java are also objects, so when your subscript crosses the border, you will receive an exception. The C ++ array is obviously faster than Java because it does not check the index. (4) in Java, the string "123" is also an object, and in C ++, it is indeed a const char *. The most common mistake is the string Terminator. However, Java and C ++ have the same optimization for this const char * character. Try the following code: string a = "123"; string B = "123 "; if (A = B) {system. out. println ("OK");} c ++ code: const char * P = "123"; const char * q = "123"; if (q = P) {STD: cout <"OK" <STD: Endl;} (5) All object methods in Java are virtual, except for the methods declared as final. (6) There is no operator overload (7) language-level serialization mechanism, and C ++ can also be implemented. Haha, look at the template mode in the C ++ expert conversation to achieve serialization. (8) language-level thread classes are extremely compatible with mutex classes (9) language-level exception systems. There are few exceptions in C ++, just the ones in STL. Of course, C ++ requires an efficient (10) Java reflection mechanism. You can see it from the reflection mechanism, java and C ++ are not comparable at all. Can the compiler compare with the platform. I said on the company forum that day that Java is a script, and other people are still arguing with me. I think I am bored.