Intermediate/Advanced Java Programming Books?
January 20, 2015 2:56 PM   Subscribe

I'm a software developer with several years of experience under my belt. Lately, I've been working with lots of Java code, but have very little formal Java training. Unfortunately, most of the resources that I've found seem to target people with little/no programming experience OR lots of basic Java experience. Can anybody recommend books or other resources that teach Java, from the perspective of a developer who is already experienced with OOP and other C-style languages?

I'm not necessarily looking for "advanced" learning materials -- I'd like something that includes a key rundown of the ways that Java differs from other languages, as well as any key "gotchas" that I need to be aware of.

Basically, I want a resource that can tell me "WTF is a Bean?" that doesn't re-explain OOP, but discusses the nuances/quirks of Java's class system.
posted by schmod to Technology (7 answers total) 11 users marked this as a favorite
Learn X in Y Minutes covers the basics but doesn't get into, y'know, beans, or plates thereof.
posted by fedward at 3:13 PM on January 20, 2015

Best answer: I'd try Effective Java and possibly Well Grounded Java Developer. I have read them both recently, definitely helped going from I know OOP to using Java well.
posted by disaster77 at 3:27 PM on January 20, 2015 [6 favorites]

Best answer: effective java has been the goto book on any team i hsve worked on where experienced devs were being brought up to speed on java.

edit: or what disaster77 said.
posted by phil at 3:27 PM on January 20, 2015

Nth-ing Effective Java by Joshua Bloch. Very good for this developer who was away from Java for a while (before annotations, generics, enums, etc.) and needed to find out what to adopt, what to throw away, and why.
posted by kurumi at 4:31 PM on January 20, 2015

(Effective Java 2nd Edition is the one that was written after Java 5, and has coverage of generics etc)
posted by thelonius at 5:28 PM on January 20, 2015

Best answer: What OOP languages do you know?
If you know C#/.NET, then this is a good treatment.

I've done a fair amount of bouncing around between languages and here are the things that are the biggest gotchas:
Type erasure - you can't use reflection on generic types because of it
There is exactly one unsigned integer, char.
The IO package gets in your way more often than it helps.
You can't really create closures because of the half-assed approach to the free/bound problem.
Get used to doing a lot of boilerplate code for common code patterns like broadcaster/listener (ie, events), properties, etc.
Generics only work on objects, not scalars.
Jar files aren't assemblies and you can't reflect over them (easily).
There's no decent way to have "types I can see throughout my packages but are hidden from you" therefore, types may get stuffed into the same package to get that effect and factories will proliferate.
I love the as operator in C# and was happy that you could make somethine roughly equivalent in Java that doesn't suck too badly:
public class Cast {
    public static  T as(Object o, Class cl) {
        if (o == null) return null;
        return cl.isInstance(o) ? cl.cast(o) : null;

Which is used something like Bar bar =, Bar.class); which is equivalent to C# Bar bar = o as Bar;
Enums aren't enums. They are named singleton classes and the prescribed way of working with them as bit fields is EnumSet. Which stinks. Or you could just use int constants that are public, not type strong, and have very little context. Which sucks. But hey, you can create an enum which contains longitude and latitude values and an instance named BUENOS_ARES. Did I mention that they're named singletons? I think I did.
I like using Iterable types and combinators etc and Java just added those in the current version. If you're not compiling against that, you have to do it yourself (and use anonymous inner classes instead of lambda expressions).
Retention of Java Annotations is off by default (different from C#).
case statements don't require a break. Surprise!
Use one element arrays or AtomicReference to pass values by reference.
There is a 64K limit to elements in a class file including code and constants. I've blown past this several times.

posted by plinth at 6:42 PM on January 20, 2015 [1 favorite]

Response by poster: Thanks folks! I'll have to check out Effective Java.

Some background: My background is primarily in scripting languages (plus some C++). Portions of our codebase are a few years old, so it'd be great to have some perspective on patterns that have fallen out of favor.
posted by schmod at 7:08 AM on January 21, 2015

« Older Buying Life Insurance and Funeral Insurance for...   |   Cool, easy songs in Japanese. Newer »
This thread is closed to new comments.