Win a copy of Spring Boot in Practice this week in the Spring forum!

Trisha Gee

+ Follow
since Jun 13, 2013
Trisha likes ...
IntelliJ IDE Java
Trisha has been working with Java since 1997, when her university was forward-looking enough to adopt this “shiny new” language to teach computer science. Since then, she’s worked as a developer and consultant, creating Java applications in a range of industries including banking, manufacturing, nonprofit, and low-latency financial trading.

Trisha is super passionate about sharing all the stuff she learned the hard way during those years as a developer, so she became a Developer Advocate to give her an excuse to write blog posts, speak at conferences, and create videos to pass on some of her knowledge. She spent five years as a Java Developer Advocate at JetBrains, and another two years leading the JetBrains Java Advocacy team. During this time she learned a lot about the kinds of problems real Java developers face.
Seville, Spain
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Trisha Gee

3 weeks ago

Campbell Ritchie wrote:Does anybody use all the new features at all? What do you say about such features? Do you say, “There are other features but this book isn't big enough,” or do you simply keep quiet about them?
What about “new” features like try with resources and using a Path object to read a file? Half the people on this forum seem not to have heard of them, and they have been out for thirteen years.

Yes great point. Our approach was to cover those features we've seen a lot "in the wild", and therefore chances are most Java programmers will need to use them, or at leasr read them, during their career. For that reason, features like try with resources, Path, new IO (even some of the stuff that was around when the old book was written but didn't make it into the book), and "small but super helpful" features like underscores in number literals were included into this version. Other features that were in the second edition, but have since been replaced, or generally fallen out of use, have been removed from this edition, or the topic slimmed down.

Languages evolve, and embracing that is part of the challenge of this job!
4 weeks ago
Modules is mentioned and given a very brief intro, mostly because it's hard to understand the current javadocs without having some idea of the modules in the jdk. We didn't cover creating a modular application, as it's unlikely beginners will have to do that. More senior developers can use a range of resources to get that info (including some of my talks and articles!)

concurrentmodificationexception is covered, we explain what it is and what causes it, and some approaches to avoid it.
4 weeks ago
It's not designed as a certification guide, it's more of an introduction to the key features in modern Java. We did look at the certification requirements to guide us in what sort of things to teach (it helped us decide which topics to cover for concurrency, for example), but you'll probably need a true certification book if you want to get your certification.
4 weeks ago
1. Yes, we had Spring (along with other common frameworks) in mind when we wrote the book, so we do lay the groundwork in Head First Java for you to go off and learn Spring (for example, we cover Annotations and where they're used, which is important for understanding and writing Spring code.

2. I'm not sure I can comment on this in this day and age. I was writing Java EE code, Spring code, and using JSPs and servlets "back in the day" and reading "Head First Servlets and JSP" significantly improved my understanding, and my code. However, most frameworks these days hide a lot of the details of the servlets that sit under these frameworks, and we're often using JavaScript or other technologies to write the UI (not raw JSPs). So, these older books may provide some useful background and understanding of how the core, under-the-covers technologies work, but at the syntax and configuration level, I think both Spring and Java EE have moved on a long way since then. Spring itself has really good reference documentation and tutorials, and there are lots of great tutorials out there on the web by third parties.

3. I would love to keep Head First Java moving at a way that keeps pace with Java (but not a new book every 6 months!!). I think we'd have to look at when big new features come out and see if that's worth adding to the book. Maybe one huge feature (like lambdas and streams, and generics, in the past) or a number of smaller-but-important ones (like the upcoming updates to concurrency, or more pattern-matching features) might make it worthwhile updating the book. One of the things I personally realised when helping to write this update, is that developers who are beginners don't need to know ALL the new features. In my day job as a Developer Advocate I was often teaching developers all the new syntax as it came out, but in reality a) very few organisations are using the latest version of Java as it comes out and b) some of these features are small enough, and understandable enough, that if you come across them in the real world you'll probably understand it.

Another challenge is that we don't really see "common practices" for new features until people have been using them for a couple of years at least. You could argue that Head First Java 3rd edition is a bit late for Java 8 (lambdas and streams), but it actually gave us the advantage that we could focus on teaching just the bits that developers have actually been using.

Head First Java needs to focus on the very core of Java, give a good grounding to all the basics, and the developers should be equipped to level up further as they go out into the real world.
4 weeks ago
Hi Geoff,

We tried to cover some of the common problems you'll run into when writing multi-threaded code in Chapter 18, and offer some suggestions on how to avoid them. Of course, one suggestion (taken very seriously by a company I used to work for, who wrote very high-speed applications) is to not use concurrency at all! One service = one thread = one CPU. Another suggestion, which we cover a few times in the book, is to limit which state, or data, can be written to by multiple threads (reading by multiple threads is usually not a problem), and make it clear which data might lead to contention so it's easier to reason about any potential issues. Using immutable objects where possible is one way to embrace this approach.

Deadlock is another common problem, a topic on which I'm sure many books and articles have been written! A simplistic approach to avoid or minimise this as a possibility is to control the order in which threads can access resources, and/or to use timeouts.

I got very excited writing some of the concurrency stuff in the book and could have written a whole book on just that topic! Fortunately, Brian Goetz has already done so, so I'll recommend his book instead.
4 weeks ago
It gives an overview of constructors - what they're for and some of the rules, like the one you've just mentioned about no-args constructors.

It talks about the garbage collector - what it is, what it does, why is it important.

It also gives an overview of how memory is used by your Java application, e.g. the stack and the heap. This isn't mandatory for understanding how to write the syntax, but it is very helpful to understand what's going on under the hood, and why certain patterns might be adopted by developers writing Java.

This chapter is particularly useful if you have come from a language that doesn't have a garbage collector, or if maybe your language did, but you didn't realise how memory was being used and re-used.
4 weeks ago
Given the excellent work Jeanne and Scott do, I wouldn't want to compete with that! They have much more expertise than I in that area, I'll leave it to them
4 weeks ago
For me, I learnt Java at university in 1997-2001, I started with Java 1.1/1.2 there. I worked with Java after I graduated (learning about servlets and JSPs, and passed my certification on these technologies with help from Bert and Kathy's book!), and generally learnt new features of Java as the newer versions of Java were adopted by the place where I worked.

So the main reason I got into Java was because of my university. But I also had experience with the Microsoft stack (back then it was Visual Basic and COM objects) and web development. I went the Java route because of the "Write Once Run Anywhere" thing - I saw it used at large organisations, running on Unix boxes, mid-sized companies running on any spare Windows box, and startups using Linux. The open source community, frameworks like Spring, and a choice of IDEs made it a more interesting ecosystem to me than the alternatives.
4 weeks ago

The previous version of the book builds up a music player over the last few chapters of the book, to demo GUI code, networking, and threading. With this version, we brought that code up to date (specifically networking and threading code changed in Java 7 and later), and we added so many examples of how to use the most common concurrency features (many of which were introduced in Java 7 and later) that we had to create a whole new chapter for the book!

Working on the concurrency chapters (chapters 17 and 18) was one of the most challenging and interesting parts of updating this book.
4 weeks ago
Bert and I originally started talking back in 2014, the idea was to write an update which brought the book up to Java 8 (lambdas and streams) which came out that year. We spent quite a while researching what we wanted to do for that version! With various life events, and then Java moving much much faster after Java 9 (2018), it became quite tricky to work out what should or should not be in the book, and how much Bert and Kathy wanted to change it. I'm really pleased they invited me along for the ride to get this version out! With this version we did have an incentive to get it out to cover Java 17 (September 2021), because that was the next "Long Term Release" after Java 11, so it seemed like a good time to draw a line under all the features we wanted to cover and get something out there for everyone.
4 weeks ago
> if you are a Java 1.5 certified, that has worked a lot with Java 8, where do you start to catch up with the latest versions? does your book cover it all?

The book covers up to Java 17, and we've tried to pick the key features you'll use, or see in real life code (like lambdas and streams from 8, the convenience factory methods from Java 9, and a brief tour of records from Java 17). I've actually given talks basically on how to level up from Java 8 to more recent versions of Java, covering the key syntax and features that are most interesting to Java, most of the research I did for those talks ended up being how we decided what to cover in the book. So, short version is, the book covers the majority of what you need to know. Anything that isn't covered, there are talks, blogs and videos on, some of which I did

> and last but not least... Do you guys have a favorite new feature? pleaase explain

Records are my favourite new feature! I'm not one to complain about "boilerplate code" in Java, I've worked with it for so long I'm comfortable with classes with getters, setters, hashcode, toString and equals methods, but it really is lovely to work with a data class which is defined just using a couple of lines of code.
4 weeks ago
All the GUI code is swing, not AWT. Yes, layout managers are covered (BorderLayout, BoxLayout, FlowLayout).

I don't think the EDT was explicitly mentioned in the Swing chapters. We do cover why you need multiple threads and how to use them in chapters 17 and 18, but not the specifics of how threading works in Swing.

4 weeks ago
Hi Esteban,

Teaching streams was a challenge! Head First is always story-driven and example-driven, and we spent a long time trying to figure out the story, the "why should you care" about streams. Some of the other later features (var, records, shell) could also be a challenge for Head First - we covered these in the appendix, so the style of teaching there was a little different, as it moves faster and goes in less depth.

The core of the book remains as it ever was. The introductory chapters, in particular, haven't changed much, as the fundamentals behind what Java (and object oriented programming) is haven't changed much, although we did update some of the analogies and examples. As the book progresses, the chapters generally had more updates, and often big pieces were added to cover new features, or updated practices, that are now commonly used. We significantly updated the chapter on collections to include lots of new Java features that have been added since the last book, and we added a whole chapter on lambdas and streams, which is probably the biggest, and most commonly-used, new feature added to Java since the second edition of the book. We also did big updates to the sections on concurrency to cover the many features that have been added since the last edition of the book.

Overall though, we hope the book retains the same "feel" as the last two editions, we hope the new material flows seamlessly from the classic content.
4 weeks ago