Tag: java

Breaking Down Java’s “Hello World”

The first piece of code most Java students see is the “Hello World” application. Despite the simplicity of what the program does, the code itself has a lot going on. There are words like class, public, static, void, and String[]. Why is all of this code here, and what does it do? In this blog post, we’ll break down Java’s “Hello World” program, and explain what all of the component pieces actually mean.

Singletons with Initialization Methods

The singleton design pattern guarantees that only one instance of a given class will be constructed. But, how can we address any exceptions that get thrown while this instance is being created? In today’s post, we’ll show how this issue can be solved using a special singleton initialization method, along with Java’s standard IllegalStateException class.

Helper Methods and Code Readability

Helper methods, or helper functions, are smaller pieces of code that perform part of an overall task. Often, when we write helper methods, it’s because we want to factor out a piece of code that’s common across multiple higher-level methods. But, we shouldn’t be afraid to write helper methods just for the sake of improved readability in a single algorithm as well.

Making Objects Immutable

This blog post describes what immutable objects are in object-oriented programming. After reading this post, you should be able to implement immutable objects, and understand how they can be used to prevent unintended side effects in our code.