C ++ and Java are object-oriented programming languages. But, both languages are different from each other in many ways.

C ++Java
C++ is platform-dependent.ava is platform-independent.
C++ is mainly used for system programming.It is widely used in Windows, web-based, business, and mobile applications.
C++ was designed for systems and applications programming. It was an extension of C programming language.Java was designed and built as an interpreter for printing systems, but it was later extended as network computing support. It was designed to be easy to do and accessible to a wider audience.
Memory management in C++ is manual.In Java the memory management is system-controlled.
C++ supports pointers. You can write pointer program in C++.Java supports pointer internally. However, you can't write the pointer program in java.
C++ supports structures and unions.Java doesn't support structures and unions.
C++ creates a new inheritance tree always.Java uses a single inheritance tree always because all classes are the child of Object class in java. The object class is the root of the inheritance tree in java.
C++ is an object-oriented language. However, in C language, single root hierarchy is not possible.Java is also an object-oriented language. However, everything (except fundamental types) is an object in Java. It is a single root hierarchy as everything gets derived from java.lang.Object.
C++ doesn't support documentation comment.Java supports documentation comment (/** ... */) to create documentation for java source code.

C++ Example

#include <iostream>  
using namespace std;  
int main() {  
   cout << "Hello World!";  
   return 0;  

Java Example

class Simple{  
    public static void main(String args[]){  
     System.out.println("Hello World");