Java interfaces

An interface is a like a class — well not really — it’s an interface, it contains 100% abstract methods. There is an explanation on abstract methods in this post . When you define interfaces, you are not reusing any behavior, you are enforcing behavior, you are guaranteeing that whoever inherits this interface, will provide [...]

Java array basics

An array is a data structure that allows you access and manage many variables using a uniform name. Imagine it like a pigeon hole, with rows and columns, you can identify a specific location in a pigeon by addressing it using row and column coordinates; Now imagine how that can be a useful thing if [...]

Java constructors

Constructors are special method — Let me take that back, they are not methods, they are constructors, they just look a bit like methods. 

Abstract classes

A class with at least one abstract method, is an abstract class (should be defined as an abstract class) – by this definition, a Java class becomes concrete when the following 2 conditions are met. There are no abstract methods defined inside the class The abstract modifier is not preceding the class keyword on the [...]

Final classes

Final classes are classes that cannot be inherited. It might be confusing at first, specially knowing that one of the benefits of object oriented programming is the ability to re-use functionality via inheritance, so why would we want to prevent inheritance?  Consider this scenario; You are a consultant, you have been asked to write a [...]

An instance of a class is called an object

This phrase is very common in Java literature, hence we need to have a better understanding of what it means. Remember when we defined a class on Java class fundamentals, we talked about its parts, and how we’re supposed to define it, now we’ll talk about it and we’re going to include object in the [...]

Java classes, a deeper look

If you haven’t read the Java class fundamentals, read that first, then come back here, you will need an high level understanding of Java classes first. I left out some details during the introduction on Java class fundamentals, for good reason, it makes the article a bit easier to understand, so why another article on [...]

Java packages

Java packages provides a directory like or folder like structure that allows you to organize your Java classes. It also enables you to implement stricter access control at a class level, state and method level. When you create a non-trivial application, the number of classes could easily be in the hundreds, you will eventually want [...]

How to make Java objects talk to each other

One Java object can talk to another Java object by sending and responding to messages. So what are messages in terms of Java codes? The methods that you define inside your classes constitutes the messages, hence if you don’t define any method inside your classes (what good are they then?), then there is no invoke-able [...]

Java class fundamentals

Java classes makes creation of Java objects possible, classes and objects are inseparable. I’m not really sure how I can make the distinction clear between classes and objects, I’m sure that by now there is a good chance you heard about a class being a “cookie cutter” or a “blue print” for objects. So let [...]