By: Abinaya Viewed: 697 times Printer Friendly Format
There are a number of features in Java that have no equivalent in C++. Perhaps the three most important are multithreading, packages, and interfaces, but there are several others that enrich the Java programming environment as well.
- Multithreading allows two or more pieces
of the same program to
execute concurrently. Further, this approach to concurrence is supported at the
language 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. While
both methods allow for concurrent execution of two or more threads, Java's approach
is cleaner and easier to use.
- There is no feature in C++ that directly corresponds to a Java
package. The closest
similarity 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 and
using a package in Java.
- The Java interface is somewhat similar to a C++ abstract class.
(An abstract class in
C++ is a class that contains at least one pure virtual function.) For example, it is
impossible to create an instance of a C++ abstract class or a Java interface. Both are
used to specify a consistent interface that subclasses will implement. The main
difference is that an interface more cleanly represents this concept.
- Java has a streamlined approach to memory allocation. Like C++,
it supports the new
keyword. However, it does not have delete. Instead, when the last reference to an
object is destroyed, the object, itself, is automatically deleted the next time that
garbage 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 the
names and parameters. Also, since all of the Java API library is object-oriented, and
only a portion of the C++ library is, there will be differences in the way library routines
- The break and continue statements have been enhanced in Java
to accept labels as
- The char type in Java declares 16-bit-wide Unicode
characters. This makes them
similar 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 third
comment 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 the
standard string class type provided by C++. Of course, in C++ string is only available if
you include its class declarations in your program. It is not a built-in type.
Most Viewed Articles (in Java )
Latest Articles (in Java)
Comment on this tutorial
- Cloud Computing
- Java Beans
- Mac OS X
- Office 365
- Tech Reviews
Subscribe to Tutorials
4. thank u very much for providing such useful inform
View Tutorial By: vinay patel at 2012-08-28 15:17:07
7. One thing I like most about your tutorials is that
View Tutorial By: Aliaksandra at 2014-09-25 04:01:26