Differences Between C++ and Java

So I went to the following page: http://en.wikipedia.org/wiki/Comparison_of_Java_and_C%2B%2B and picked out three differences between C++ and Java to summarize.

Default arguments for a function (or a method)

C++ allows default values for parameters of a function (or a method). Java does not. Method overloading can be used to obtain similar results in Java but generates redundant code.

Because C++ supports prototypes, a programmer might create a prototype and set its default value, rather than setting the default value in the function definition. In fact, that method is how to set default values when using function prototypes. Conversely, in Java you cannot set a parameter’s value directly in the function definition. Instead, you might simulate optional parameters by what’s known as method overloading. Method overloading simply is creating multiple methods, each with a different number of parameters but with exactly the same names.

Code documentation

C++ doesn’t have any built-in documentation mechanism, whereas Java has Javadoc.

One important aspect about programming is leaving comments for developers. Leaving comments helps both the author and future programmer understand the code's purpose and where it might be used. This type of reference makes programming much easier for all people involved. It might even remove assumptions and guessing. Documentation mechanisms certainly help to keep a standard commenting structure and automate the task of generating complete documentation for the program’s code.

Requirement to compile

The required code you need to compile for C++ is a function. The requirement for Java is a class.

In C++, the main() function is all that is needed for the program to run. As a descendant of C, C++ inherits this trait. Similarly, the Java Virtual Machine will look for a main() method on program startup. An array of strings, according to the Java Language Specification, will be passed to the method. The difference between C++ and Java, however, is: in Java, main() must be within a class and C++ does not.

  Page Turn