Answers.Body: <p>I'd like to reassure you that if you are accustomed to C++ Java won't be something really difficult to understand. Yeah, it's another language with its peculiarities but nothing enormously hard to cope with.  Start from the basics - this rule always works the best.
  It's OK to be afraid of new things but they are interesting challenges at the same time.
  Regarding the books, I recommend you this one - Java: Programming Basics for Absolute Beginners by Nathan Clark (found it in the list with various <a href="https://codegym.cc/groups/posts/best-java-books-for-beginners" rel="nofollow noreferrer">best java books</a>). It helps to structure the programming language and to get its concept even for a newbie.</p>
  <p>Along with books, you may add some online java courses. It's a great starter pack and the point where to start from.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-25T12:08:56.257Z
Answers.LastActivityDate: 2021-03-25T12:08:56.257Z
Answers.UserDisplayName: Lexxxis
Answers.Body: <p>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.</p>
  <p>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.</p>
  <p>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.</p>
  <p>One book I'd recommend very highly (since I know and trust one of the authors) is by <a href="https://rads.stackoverflow.com/amzn/click/com/0134477367" rel="nofollow noreferrer" rel="nofollow noreferrer">Barnes and Kölling</a>. It does, however depend on also using the <a href="https://bluej.org" rel="nofollow noreferrer">BlueJ</a> IDE which they created and is available free online.</p>
  <p>The reason I recommend it is that it introduces <em>objects</em> 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.</p>
  <hr />
  <p>An alternative that would work, if you somehow object to BlueJ is <a href="https://rads.stackoverflow.com/amzn/click/com/1119740207" rel="nofollow noreferrer" rel="nofollow noreferrer">Cay Horstmann's Big Java Early Objects</a>. 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.</p>
  <hr />
  <p>A third possibility, though it is intended more for first time programmers rather than for someone with experienced in another language, is <a href="https://rads.stackoverflow.com/amzn/click/com/0970579519" rel="nofollow noreferrer" rel="nofollow noreferrer"><em>Karel J Robot</em> by Bergin, Stehlik, Roberts, and Pattis</a>. 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 <em>Karel the Robot</em> it is an attempt to provide a minimal but complete system including a simulator in which interesting (and difficult) programs can be written.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-15T06:14:27.997Z
Answers.Text: Thanks for the insightful advice. Can I ask more about what differs the two languages specifically ? I would like to have a throughout understanding so I might not get on the wrong foot with the Java.
Answers.UserDisplayName: Long le Thanh
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-15T12:29:51.163Z
Answers.Text: An "object" in C++ is created on the stack normally, though you can also create one on the heap. In Java it is always created on the heap and will be garbage collected automatically. Every C++ program that creates objects on the heap has to also have a management strategy for them. The difference may seem small but affects how you think about problem solution. There is no "natural" dynamic polymorphism in C++.
Answers.UserDisplayName: Buffy
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-16T15:50:47.093Z
Answers.Text: Re, "an 'object' in C++ is created on the stack..." I think what you are trying to say is that a C++ object can be stored _in a variable._ A variable could be a local (on the stack), or it could be elsewhere. And, a C++ assignment, `a=b;` is a function call that is conventionally expected to create a _copy_ of object `b` in the variable `a` after it first _destroys_ the previous value of `a`. In Java, on the other hand, a variable can never hold an object, it can only ever hold a _reference_ to an object, and an assignment can only ever create a new reference to the same object.
Answers.UserDisplayName: Solomon Slow
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-16T15:54:51.807Z
Answers.Text: @SolomonSlow, yes, all of that is true and well stated. Thanks.
Answers.UserDisplayName: Buffy
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-14T16:31:47.007Z
Answers.LastActivityDate: 2021-02-14T17:30:17.737Z
Answers.LastEditDate: 2021-02-14T17:30:17.737Z
Answers.UserDisplayName: Buffy
Body: <p>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?</p>
  
Tags: <self-learning><programming><java>
Title: How to learn Java as a beginner?
ThreadText: # How to learn Java as a beginner?
  
  (Asked by: username_0 on 2021-02-14)
  
  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?
  
  **Tags:** self-learning, programming, java
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2021-02-14. Score: 2 | Accepted answer
  
  The first thing you need to understand is that your second language is, perhaps the hardest of all to learn. You already know "how to program" 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](https://rads.stackoverflow.com/amzn/click/com/0134477367). It does, however depend on also using the [BlueJ](https://bluej.org) 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](https://rads.stackoverflow.com/amzn/click/com/1119740207). 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](https://rads.stackoverflow.com/amzn/click/com/0970579519). 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.
  
  > **Comments:**
  > **username_0**: Thanks for the insightful advice. Can I ask more about what differs the two languages specifically ? I would like to have a throughout understanding so I might not get on the wrong foot with the Java.  
  > **username_2**: An "object" in C++ is created on the stack normally, though you can also create one on the heap. In Java it is always created on the heap and will be garbage collected automatically. Every C++ program that creates objects on the heap has to also have a management strategy for them. The difference may seem small but affects how you think about problem solution. There is no "natural" dynamic polymorphism in C++.  
  > **username_3**: Re, "an 'object' in C++ is created on the stack..." I think what you are trying to say is that a C++ object can be stored _in a variable._ A variable could be a local (on the stack), or it could be elsewhere. And, a C++ assignment, `a=b;` is a function call that is conventionally expected to create a _copy_ of object `b` in the variable `a` after it first _destroys_ the previous value of `a`. In Java, on the other hand, a variable can never hold an object, it can only ever hold a _reference_ to an object, and an assignment can only ever create a new reference to the same object.  
  > **username_2**: @username_3, yes, all of that is true and well stated. Thanks.  
  
  ---
  
  ### Answer by username_1 on 2021-03-25. Score: 2
  
  I'd like to reassure you that if you are accustomed to C++ Java won't be something really difficult to understand. Yeah, it's another language with its peculiarities but nothing enormously hard to cope with. Start from the basics - this rule always works the best.
  It's OK to be afraid of new things but they are interesting challenges at the same time.
  Regarding the books, I recommend you this one - Java: Programming Basics for Absolute Beginners by Nathan Clark (found it in the list with various [best java books](https://codegym.cc/groups/posts/best-java-books-for-beginners)). It helps to structure the programming language and to get its concept even for a newbie.
  
  Along with books, you may add some online java courses. It's a great starter pack and the point where to start from.
  
  
  ---
  
  