Better println() Debugging in Java

In today’s blog post, we’ll look at one way to improve System.out.println() debugging in Java. Namely, let’s make it so our println() debugging outputs include the name of the source code file, the method name, and the line number where the output happens. Debugging with println() is fast and easy, and it’s not going anywhere; so, let’s just make its output more useful.

The Big Three in Java, Part Three: hashCode()

For part three in this series of four blog posts, we look at another one of Java’s “big three” methods: Object.hashCode(). This method returns an integer value that can be used to split objects into buckets. One critical requirement is that any two objects that compare as equal must return the same hash code. We explore how to meet that requirement, while also writing hashCode() methods that are effective and efficient.

The Big Three in Java, Part Two: equals(Object)

In the second of a series of four blog posts, we explore another one of the “big three” methods in Java: the Object.equals(Object) method. This method allows us to compare two objects of a given type for value equality, instead of just reference equality. That is, this method can compare the internal state of two objects to determine if they’re equal.

The Big Three in Java, Part One: toString()

In the first of a series of four blog posts, we’ll explore one of the “big three” methods in Java: the Object.toString() method. This method generates a String representation of an object and its state. By overriding the Object.toString() method in any class that we write, we can customize, for example, how objects of that class are displayed when printed to the console.