Cay Horstmann Core Java

Core Java, Volume I – Fundamentals by Cay Horstmann is one of the most known and respected books about Java. You are reading this review most likely because somebody recommended that book to you and you wanted to learn about it more. When I was looking for new Java books some time ago, almost every forum or blog was recommending to give Core Java a try. The first edition of this book was released in 1996 covering the very first edition of Java. Today, 20 years later, we can read the tenth edition covering Java 8.

The first thing that you will notice about this book is its size – the book consist of a little over 1000 pages. It’s funny to see the word “fundamentals” on the cover of a so big book. Don’t get scared! While Core Java covers Java fundamentals in detail, it also goes quite far beyond them as well. Finishing this book will give you a solid understanding of the most important parts of Java.

One thing that actually made me worried about Core Java is if it contains fillers. A “filler” is text that does not bring any educational value to a book – it is written only to increase page count. If you ever saw in a book an n-th example showing the same very simple concept, or some unnecessary story, it was most likely a filler to increase page count to required amount. Thankfully, I quickly realized that Cay Horstmann in his Core Java didn’t put any fillers. Quite opposite. It consist of really well written text with all concepts explained simply and shorty. No unnecessary extended examples or talking about unrelated things. Those 1000 pages are pure knowledge.

When you open the book, the first thing you will see is the table of contents. A quite big table of contents – it takes good 14 pages. Despite its size, it’s very easy to traverse through its contents when you are looking for something specific. I really like its construction, because it allows to use the book as a reference when you want to recall something during actual programming. You can find the entire table of contents at the end of this review to get the idea what the book covers.

The general construction and structure of the book makes it very easy to read. There may be chapters that you are not interested in, like a big section about GUI programming. Thanks to the book construction, you can safely drop the chapters you don’t want to read without having to worry that you will miss something that you care about. When you will look at the table of contents you will always get a clear image of what given chapter covers.

Core Java begins with a general description of the Java Platform. It’s very useful especially for people coming from other languages. It can give you an idea what Java is and what it isn’t. The author also discusses a few common misconceptions and stereotypes about Java.

After learning about the ideas and concepts behind Java, you will learn how to prepare your work environment. You will learn how to install JDK (Java Development Kit), use command-line tools for compiling and running Java applications, and how to integrate Java with IDEs like Eclipse.

The next chapter consist of about 80 pages and discusses the fundamental structures of Java. Data types, operators, basic input and output and control flow are examples of what is covered. What I liked in this chapter is that Cay Horstmann explains this topic very simply and clearly. He does not focuses on explanations what a variable or a for-loop is – he assumes that you know what those elements. He focuses instead on explaining how those elements are implemented and used specifically in Java.

After learning about the fundamentals about basic Java structures, you will learn the most important concept in Java – object oriented programming. If you never worked with object oriented programming before then don’t worry – Core Java describes the entire concept in very detail. The first chapter discussing this concept is about the absolute basics: classes and objects. The next chapter covers inheritance and related concepts like polymorphism. Finally you will learn about interfaces and inner classes, as well as lambda expressions (a new feature that came with Java 8). While lambdas are characteristic to functional programming, Java engineers implemented them in a very elegant way using functional interfaces. The author also covers the Reflection API that allows to work with classes and objects at runtime.

After solid portion of knowledge about object oriented programming, you will learn about one of my most favorite mechanisms in Java – exceptions. Java has a very well implemented exceptions mechanism allowing to handle errors in elegant and efficient way. Beside exceptions, the author covers also assertions and logging mechanisms.

One full chapter in Core Java is fully dedicated to generic programming. I was actually quite surprised to find such topic in a “fundamentals” book. If you are a fan of C++ STL, you will love this part of the book. In this chapter the author explains in an interesting way how generic programming is utilized in Java and how to write own generic code. In the next chapter Cay Horstmann covered Java collections. This chapter covers all you need to start working with tools like lists, tree sets, queues, stacks or maps. As a side note, if you are interested in generic programming from the mathematical side, read my review of the From Mathematics to Generic Programming book written by Daniel Rose and Alexander Stepanov, the creator of C++ STL.

A solid part of the book, consisting of almost 280 pages, is dedicated for programming GUIs (graphical user interfaces) using Swing. If you are not interested in this topic, you can safely skip those chapters. You will not miss any important concepts about the core Java itself.

Chapter 13 discusses how proper Java applications deployment is done. This topic is very often not covered in detail, so finding it in Core Java was a nice surprise.

The last chapter is dedicated for concurrency. Cay Horstmann took this chapter very seriously and got it discussed a little further that just fundamentals. With this chapter, you will learn how to write multi-threaded applications, utilizing the potential of multi-core processors.

Important thing to mention about Core Java is that despite the book is targeted for Java beginners (and actual Java programmers as well), it’s not suitable for people that are new to computer programming. This book requires prior knowledge of common programming concepts like control structures, data types, variables. Without prior experience in programming it will be difficult for you to understand the book. On the other hand. if you are an experienced programmer tired of reading for hundredth time what a variable is, you will totally love this book.

If you are interested in Oracle Java certifications, like OCA and OCP, this book is a great resource for exam preparation. I have used this book for preparations for my OCA exam. The book covered all the exam requirements in very detail, making me very relaxed before the exam and allowed to pass it very easily. I am now using it in preparation for OCP exam and I can recommend it for anybody preparing for those exams.

Summarizing, this is a wonderful book about Java, and one of the best book IT in general in my opinion. If you are a programmer seriously thinking about Java, then this is a mandatory position on your bookshelf.

Buy Core Java Volume I: Fundamentals on Amazon.

PS: You may have heard about Core Java for the Impatient book, written by Cay Horstmann as well. I found people often asked on Internet forums about the difference between those two books. Core Java for the Impatient is a shorter version with less chapters than Core Java. It contains a good kickstart to Java if you want to get usable skills fast and you have prior knowledge with other languages. I have read it myself and I enjoyed it a lot. If you want to get started with Java real fast, Core Java for the Impatient is the book for you. If you look for more wide and in-detail knowledge, pick Core Java.


Core Java Volume I: Fundamentals – Table of Contents

Chapter 1: An Introduction to Java
1.1 Java as a Programming Platform
1.2 The Java “White Paper” Buzzwords
1.3 Java Applets and the Internet
1.4 A Short History of Java
1.5 Common Misconceptions about JavaChapter 2: The Java Programming Environment
2.1 Installing the Java Development Kit
2.2 Using the Command-Line Tools
2.3 Using an Integrated Development Environment
2.4 Running a Graphical Application
2.5 Building and Running AppletsChapter 3: Fundamental Programming Structures in Java
3.1 A Simple Java Program
3.3 Data Types
3.4 Variables
3.5 Operators
3.6 Strings
3.7 Input and Output
3.8 Control Flow
3.9 Big Numbers 1
3.10 Arrays

Chapter 4: Objects and Classes
4.1 Introduction to Object-Oriented Programming
4.2 Using Predefined Classes
4.3 Defining Your Own Classes
4.4 Static Fields and Methods
4.5 Method Parameters
4.6 Object Construction
4.7 Packages
4.8 The Class Path
4.9 Documentation Comments
4.10 Class Design Hints

Chapter 5: Inheritance
5.1 Classes, Superclasses, and Subclasses
5.2 Object: The Cosmic Superclass
5.3 Generic Array Lists
5.4 Object Wrappers and Autoboxing
5.5 Methods with a Variable Number of Parameters
5.6 Enumeration Classes
5.7 Reflection
5.8 Design Hints for Inheritance

Chapter 6: Interfaces, Lambda Expressions, and Inner Classes
6.1 Interfaces
6.2 Examples of Interfaces
6.3 Lambda Expressions
6.4 Inner Classes
6.5 Proxies

Chapter 7: Exceptions, Assertions, and Logging
7.1 Dealing with Errors
7.2 Catching Exceptions
7.3 Tips for Using Exceptions
7.4 Using Assertions
7.5 Logging
7.6 Debugging Tips

Chapter 8: Generic Programming
8.1 Why Generic Programming?
8.2 Defining a Simple Generic Class
8.3 Generic Methods
8.4 Bounds for Type Variables
8.5 Generic Code and the Virtual Machine
8.6 Restrictions and Limitations
8.7 Inheritance Rules for Generic Types
8.8 Wildcard Types
8.9 Reflection and GenericsChapter 9: Collections
9.1 The Java Collections Framework
9.2 Concrete Collections
9.3 Maps
9.4 Views and Wrappers
9.5 Algorithms
9.6 Legacy CollectionsChapter 10: Graphics Programming
10.1 Introducing Swing
10.2 Creating a Frame
10.3 Positioning a Frame
10.4 Displaying Information in a Component
10.5 Working with 2D Shapes
10.6 Using Color
10.7 Using Special Fonts for Text
10.8 Displaying Images

Chapter 11: Event Handling
11.1 Basics of Event Handling
11.2 Actions
11.3 Mouse Events
11.4 The AWT Event Hierarchy

Chapter 12: User Interface Components with Swing
12.1 Swing and the Model-View-Controller Design Pattern
12.2 Introduction to Layout Management
12.3 Text Input
12.4 Choice Components
12.5 Menus
12.6 Sophisticated Layout Management
12.7 Dialog Boxes
12.8 Troubleshooting GUI Programs

Chapter 13: Deploying Java Applications
13.1 JAR Files
13.2 Storage of Application Preferences
13.3 Service Loaders
13.4 Applets
13.5 Java Web Start

Chapter 14: Concurrency
14.1 What Are Threads?
14.2 Interrupting Threads
14.3 Thread States
14.4 Thread Properties
14.5 Synchronization
14.6 Blocking Queues
14.7 Thread-Safe Collections
14.8 Callables and Futures
14.9 Executors
14.10 Synchronizers
14.11 Threads and Swing