What is the best book for learning Java?

I haven’t programmed in a while. To give you an idea, I first learned FORTRAN in school and taught myself c from a book several years later. I would like to learn Java now.

What is a good book that I can use to teach myself to program in Java? I first need to understand this whole newfangled OOP thing so I am looking for a good theoretical introduction first. I also would like to learn through examples so lots of good problems are important to me as well.

Thanks.

When I go to learn Java, which will likely be relatively soon, I intend to pick up a book called something like “Algorithms and Data Structures in Java”. It makes sense for me because I’ve already been through a similar book in C++ (my native language, so to speak), and it might make sense for you because knowing basic data structures is very important for dealing with anything but a small program.

After you’ve gone through that, take a look at this book for a discussion of object-oriented programming. It’s not a very theoretical book, but the discussion of how multiple languages work goes a long way towards making it clear why your particular language works the way it does.

Thinking in Java is a good book to start with, as well as free.

Seconded. He leads you through the whole process, and while I found his examples to be somewhat longwinded and not really helpful (especially the discussion on data types, which is about three pages of very similar code, and terribly confusing to parse, especially for a new person) in general it’s a good book. Can’t beat the price, too.

I like “Agile Java” by Jeff Langr. It can be used to learn both Java and agile programming techniques. I’d ignore the bits about Ant, though. Just download Eclipse and run through the book.

I used “Java in a Nutshell” years ago and thought it was great.