- Multithreading allows two or more pieces of the same program toexecute concurrently. Further, this approach to concurrence is supported at thelanguage level. There is no parallel for this in C++. If you need to multithread a C++program, you will need to do so manually, using operating system functions. Whileboth methods allow for concurrent execution of two or more threads, Java's approachis cleaner and easier to use.
- There is no feature in C++ that directly corresponds to a Java package. The closestsimilarity is a set of library functions that use a common header file. However,constructing and using a library in C++ is completely different from constructing andusing a package in Java.
- The Java interface is somewhat similar to a C++ abstract class. (An abstract class inC++ is a class that contains at least one pure virtual function.) For example, it isimpossible to create an instance of a C++ abstract class or a Java interface. Both areused to specify a consistent interface that subclasses will implement. The maindifference is that an interface more cleanly represents this concept.
- Java has a streamlined approach to memory allocation. Like C++, it supports the newkeyword. However, it does not have delete. Instead, when the last reference to anobject is destroyed, the object, itself, is automatically deleted the next time thatgarbage collection occurs.
- Java "removes" the C++ standard library, replacing it with its own set of API classes.While there is substantial functional similarity, there are significant differences in thenames and parameters. Also, since all of the Java API library is object-oriented, andonly a portion of the C++ library is, there will be differences in the way library routinesare invoked.
- The break and continue statements have been enhanced in Java to accept labels astargets.
- The char type in Java declares 16-bit-wide Unicode characters. This makes themsimilar to C++'s wchar_t type. The use of Unicode helps ensure portability.
- Java adds the >>> operator, which performs an unsigned right shift.
- In addition to supporting single-line and multiline comments, Java adds a thirdcomment form: the documentation comment. Documentation comments begin with a/** and end with a */.
- Java contains a built-in string type called String. String is somewhat similar to thestandard string class type provided by C++. Of course, in C++ string is only available ifyou include its class declarations in your program. It is not a built-in type.
Monday, 6 January 2014
New Features Added By Java Compare to C++
About Blog No Baap -
Since 2016 BlogNoBaap has been bringing you the very best in all types of web resources. Posted daily, and delivered straight to your inbox each morning.