Since I'm taking time of from my day job I thought it's time to learn something other than C. Is there a K&R equivalent book ? Or maybe a very good site that helps the beginner ? What would you recommend as the development environment ? What classes should I start with ?
I would start with the Sun website for Java and go from there. The API specs are always helpful, and I never code Java without them (either open in a browser or with an IDE that has it built in). And if you have a question, I've found the Sun forums to be helpful too, but I believe you need an account to post there.
As for development IDEs, any text editor would work. If you want a full blown IDE, I would recommend Eclipse (my personal favorite) or NetBeans.
I think the biggest learning curve going from C to Java is not going to have to do with Java itself, but rather the fact that it's an object-oriented language.
I'd recommend Wikipedia's page on object-oriented programming to give you some information about the basic concepts, and then go from there. Once you've got that, Java's language constructs will make more sense.
I would recommend Java in a Nutshell it was very useful to me as a jump start and as a paper reference. The latest addition is twice as big as the one I have so it may not be as useful to thumb through.
I found Eclipse very easy to use as an IDE and it is Visual Studio like in it's features. There are some Java related Eclipse tutorials here.
The Java Tutorials on Sun's web site is a good place to start.
Similar to the other answers above, I recommend Head First Java and to also keep a bookmark to the Java 6 API Reference - the API reference is invaluable when working on projects. Odds are if you find yourself needing a function or a library, it's already available for you.
If you're into data structures, threads, network programming, and algorithms and are interested in trying them out in a new language, then Data Structures & Algorithms in Java isn't a bad book - the fonts make it difficult to read at times, and the code is a bit cramped on a page; however, for someone that's a "veteran" I really doubt that will provide major set backs.
Honestly, though, learning Java coming from C will probably come very quickly. With so many things going on for you automatically (memory allocation, garbage collection, etc) and with such clean error messages (forget Segmentation Fault), it's very easy to get a handle on the language.
@tom: thanks for the answer but what I'm really afraid of is that those things that come automatically will be an obstacle. For example: returning from a function and not thinking about the destructors that run in the background. But maybe I just worry too much ;-)
@those who suggested Head First Java: Is it really all that good? I've looked at "Head First Design Patterns" when learning about them, and settled on the GoF book instead. I also looked at the JavaScript I think it was and settled on an O'Rielly book. I didn't think any of the Head First books were all that great.
I would strongly recommend Effective Java by Joshua Block. It's an excellent book with a lot of practical information on how to build things in Java and how to build them right. Read the Amazon reviews. They're all positive.
I also second Bruce's recommendation for Java in a Nutshell by David Flanagan. I found it to be a very useful book when I was learning Java. I wouldn't recommend it for an experience Java programmer, but for beginners, I think it's a great book.
Don't forget the classic Bruce Eckel 'Thinking In Java' book http://mindview.net/Books/TIJ4.
I second what Matt Dillard said about object-orientation being the biggest learning curve and recommend the book Applying UML and Patterns
Books are really great, but remember that with coding it's doing that really kicks off the learning process. Some places to get started with examples are:
- The Swing Tutorial
- Java Documentation
- Sun's Java Tutorials with Examples
- Some Random Dude
- Intro to Layout Managers from IBM
- Optimizing Java for Speed
- The Java Developers Almanac 1.4
but a great book is:
- O'Reilly's Java Threads
Coming from a background as a C/C++ programmer, I found the language itself not at all problematic. The large class library, on the other hand, took much more time. Learning that instead of wanting some simple idiom like
FILE *f=fopen("foo.txt", "w");
...I'd be wanting...
PrintWriter pw=new PrintWriter(new BufferedOutputStream(new FileOutputStream("foo.txt")));
took some time. (Since Java 1.5, the above code is more concise - you can construct a PrintWriter directly with a filename as a parameter. I've left the Java 1.4 version as a better example of a learnt idiom.) If you're planning on eventual Swing programming, I'd nonetheless recommend first getting comfortable with the basics of the class library before diving into Swing/AWT, which is full of its own idioms and pitfalls.
Other people have mentioned the API docs. If you're on Windows, I strongly recommend getting the Java API docs in Windows' HTML Help format (if you're not on Windows, Wine has a HTML Help reader). Much, much quicker to browse than the plain HTML version (and more readable than the Eclipse-integrated version). The Java Language Specification is Java's equivalent to K&R, but with somewhat different goals and a much larger and more complex language to document. This (and the fact that the only book like K&R is K&R) makes it not something you'll want to read, but useful as a reference on the finer points of the language.
Any C/C++ Programmer that have to switch to Java will actually find the language quite natural (especially if you happens to understand Object-Oriented Programming Concepts).
However, I would recommend to buy (or download) Bruce Eckel book named "Thinking in Java" that is a very nice intro that should help you understand the basic concepts/libs... After that, you will have to learn the numerous libraries available to you.
Learning Java is not about syntax, it's about third-parties libs that you will most probably need
Perhaps the whole Sun book set is Java's K&R equivalent. If you are like me and want a single volume that covers all you need to get started, then I can recommend "Just Java" by Peter van der Linden. It's very well written, covers a lot of ground, but it's not one of those 1000+ pages bricks. Highly entertaining, too.
The author has also written a highly recommended C book called "Expert C Programming: Deep C Secrets".
Fast way and very rich in insight: "teach scheme -> reach Java" http://www.teach-scheme.org/
you will thank me
When I first studied Java 10 years ago, I also came from C and this book was great:
The author explains object orientation and Java for readers that are only familiar with C and the procedural paradigm.
http://www.amazon.com/Exploring-Java-2nd-OReilly/dp/1565922719
I'd recommend http://codingbat.com/
lots of great simple challenges, and even more complicated ones. with examples and hits to get you going.