Java learning is simple due to no pointers support. C/C++ Programmers can reach Java easily as Java borrowed many concepts like data type rules, control structures and arrays from C/C++. But for learning Java, C++ background is not essential as the same OOPS concepts of C++ are learnt though Java syntax.
Java comes with many unique features like platform-independent, implicit memory management etc. Let us discuss them very briefly.
One of the important features of Java is platform-independent. C/C++ program compiled on one platform (operating system) cannot be executed on a different platform. That is, where you compile, on the same platform you must execute. It is different completely with Java. A Java program compiled on platform can be executed on any other platform. Following figure makes it clear.
Hello.exe of C-lang generated on DOS platform should be executed on DOS only. But Hello.class generated by Java compiler on DOS can be executed on any platform. This makes Java most wanted in the world.
2. Implicit memory management – Garbage collection
C/C++ Programmer is overburdened with memory management code. Besides writing the code, he is also required to request the memory required to run is code. But in Java it is implicit. For this reason, Java does not support memory functions like calloc(), sizeof(), free() etc and also does not have destructors. But Java has constructors. While Java execution is going on, the objects which are not required for further in the code, known as garbage, are implicitly removed with garbage collector. That is, complete memory management in Java of either creation or removal is implicit, Java Programmer can forget and concentrate on his logic of code.
Next step is writing a simple program. It is illustrated in Java Example Compilation Execution.
Once you understand the above example, go through the following links for Java Learning in the same order; else you land in trouble in Java Learning.
1. Using Local and Instance Variables
2. Data Binding Data Hiding Encapsulation
3. Using Variables from Methods
4. Primitive Data Types
5. Data Types Default Values – No Garbage
6. OOPS concepts – introduction
7. static Keyword