News for hackers. Stuff that matters.

Ask HN: Resources for learning Java?

After 2 years of coding exclusively in PHP, I'm making the transition to Java and would like your suggestions on what are the best resources for learning the language.

If you are a Java dev, I would like to hear your story. How did you learn the language? What helped you the most? Any advice you can provide is appreciated.

( 19 comments | 7 points | on HN )
Re:Ask HN: Resources for learning Java? by yan on Tuesday December 16, 2008 @12:57PM (#399740)
If you already have experience programming (which you do) try the following: First read the wikipedia page on the language. Download a medium-sized open source project, start at main() and try to understand what it does. Then, google for features/syntax you don't understand; read comments; have the api docs open; google for languages gotchas; google for techniques you don't understand. Once you do this enough to be comfortable with the language (Shouldn't take more than a few days), try to write something on your own. Either recreate what you already wrote or try to create something just outside what you feel is within your means.

I tend to learn languages a lot faster and in a much more thorough fashion when I approach it this way.

edit: this has nothing to do with java per se, but I find it is valuable to me when trying to pick up a new language.

Re:Ask HN: Resources for learning Java? by stanley on Tuesday December 16, 2008 @03:00PM (#399939)
Thanks Yan
Re:Ask HN: Resources for learning Java? by mechanical_fish on Tuesday December 16, 2008 @12:56PM (#399739)
Years ago, I used Bruce Eckel's Thinking in Java:

http://mindview.net/Books/TIJ4

I liked it a lot at the time. No idea if that's the best thing out there now. I haven't seen the latest edition, as I haven't had to touch Java in several years.

Re:Ask HN: Resources for learning Java? by arockwell on Tuesday December 16, 2008 @02:09PM (#399855)
That was how I originally learned Java in undergrad. I think that its a pretty good book. I think that its a great introduction to the basics. A good follow up book is Effective Java by Joshua Bloch.
Re:Ask HN: Resources for learning Java? by hello_moto on Tuesday December 16, 2008 @02:43PM (#399917)
One such ordering is as follow:

1) Head First Java (Edition that covers Java 5) 2) Core Java (optional, latest edition) 3) The Java Programming Language 4th Ed _AND_ Effective Java 2nd Ed

The last resources are somewhat related. Some of the stuffs in TJPL can make EJ clearer and vice versa.

Re:Ask HN: Resources for learning Java? by tjr on Tuesday December 16, 2008 @02:51PM (#399925)
I've not done much Java for a while, but my most useful resources have been The Java Programming Language and The Java Developer's Almanac (especially the code samples, which I believe are available somewhere on java.sun.com).

Effective Java is also a great read for becoming a "better" Java programmer, but may or may not be useful to you right off the bat.

Re:Ask HN: Resources for learning Java? by ObieJazz on Tuesday December 16, 2008 @12:51PM (#399730)
http://java.sun.com/j2se/1.5.0/docs/api/

This got me through my college Java courses.

Re:Ask HN: Resources for learning Java? by yters on Tuesday December 16, 2008 @02:10PM (#399858)
Seconded. I've found the Collections section to be most helpful.

Also, if you want functional programming in your collections, check out Apache's commons collections:

http://commons.apache.org/collections/

Re:Ask HN: Resources for learning Java? by rw on Tuesday December 16, 2008 @01:46PM (#399823)
Try searching any question like this with "X for Y programmers". Example:

http://www.google.com/search?q=%22java+for+php%22+programmer...

These results aren't as good as some, such as "Java for Lisp programmers". It's a useful heuristic, anyway.

Re:Ask HN: Resources for learning Java? by bretthoerner on Tuesday December 16, 2008 @01:43PM (#399821)
I'm kinda doing the same thing but from Python. I really liked Java Precisely http://www.itu.dk/~sestoft/javaprecisely/

It doesn't try to teach you programming, it just cuts to this "this is what this is in Java" ... high signal/noise.

Re:Ask HN: Resources for learning Java? by johnyzee on Tuesday December 16, 2008 @03:39PM (#400014)
Sun's own Java Trails online tutorials are very good. They cover a lot of ground with minimal blabbering (unlike books whose authors are paid by page count).

http://java.sun.com/docs/books/tutorial/

Re:Ask HN: Resources for learning Java? by flashgordon on Tuesday December 16, 2008 @07:20PM (#400324)
On a different note why? no, really... apart from enterprise development why would you want the headache...

(by the way, ive done java since 98 up until couple of years ago when i switched to python...)

Re:Ask HN: Resources for learning Java? by critke on Tuesday December 16, 2008 @02:42PM (#399916)
Start with Hello World and try stuff: http://www.javacoffeebreak.com/java101/java101.html
Re:Ask HN: Resources for learning Java? by zupatol on Tuesday December 16, 2008 @02:55PM (#399930)
I learned a lot from the java tutorial

http://java.sun.com/docs/books/tutorial/

Re:Ask HN: Resources for learning Java? by stuartk on Tuesday December 16, 2008 @04:17PM (#400080)
Take a look at http://www.javapassion.com/

Some nice tutorials on several aspects of Java.

Re:Ask HN: Resources for learning Java? by brl on Tuesday December 16, 2008 @03:11PM (#399952)
You might like dzone.com which is a link/news site for developers that has a huge bias in favor of news about Java.
Re:Ask HN: Resources for learning Java? by krisneuharth on Tuesday December 16, 2008 @06:05PM (#400240)
Learning Java from Oreilly was a good start for me and continues to be a decent reference as time goes on.
Re:Ask HN: Resources for learning Java? by comster on Tuesday December 16, 2008 @04:15PM (#400076)
Just goto any US university teaching Comp Sci
Re:Ask HN: Resources for learning Java? by Shamiq on Tuesday December 16, 2008 @08:54PM (#400417)
They started us on Meta (an in-house branch of Scheme, built on the .NET 2 framework), then it's to C++ for the next class in the sequence.

The university is called Northwestern.