How to learn Java as a beginner? I want to start learning Java from scratch. But as a beginner, I don't know where to start or what to learn first. I have basic knowledge in C++ but Java is an entirely new area to me. Can anyone give me some instructions and good books to start properly?
The first thing you need to understand is that your second language is, perhaps the hardest of all to learn. You already know &quot;how to program&quot; and so the second language seems to get in the way of that. Alternatively you just use the second language in the same way you used the first, resulting in ugly and sub-optimal programs. So, you want to guard agains that.
It is actually somewhat easier to learn a second language if it is nothing at all like the first, since you can't try to impose habits from one language on the other and have to absorb the actual philosophy of the new language. So, Scheme, for example, after C++ (or before) forces you to think in a new way.
So, learning Java after C++ is especially difficult, since the lowest level syntax of the two is nearly the same, but the underlying philosophy (paradigm) is quite different. In particular, Java and C++ both use what they call classes but they are really different creatures.
One book I'd recommend very highly (since I know and trust one of the authors) is by Barnes and Kölling. It does, however depend on also using the BlueJ IDE which they created and is available free online.
The reason I recommend it is that it introduces objects from the beginning, which is the fundamental difference between C++ and Java. So, if you put aside what you think you know about programming and believe in the authors, you should do well. They both have a very (very) deep understanding of what Object Orientation means.

An alternative that would work, if you somehow object to BlueJ is Cay Horstmann's Big Java Early Objects. It, too, starts with objects which is my primary recommendation. I also know Cay. He also has a Late Objects version that I don't recommend for a bunch of reasons, but one is that the first part of that book would be likely to bore you. While it might seem an easier path, it won't take you where you need to go as directly as the Early Objects version.

A third possibility, though it is intended more for first time programmers rather than for someone with experienced in another language, is Karel J Robot by Bergin, Stehlik, Roberts, and Pattis. This book focuses entirely on object oriented programming in Java but does not try to teach the entire language. It does, however, provide a system in which any program can be written. Like Pattis' original Karel the Robot it is an attempt to provide a minimal but complete system including a simulator in which interesting (and difficult) programs can be written.