Skip to main content

Posts

Featured

Investigating Interfaces In Java

We sometimes need to define a protocol of behaviour that can be used by any class. For example, a car shop could have a car class defining the car features and manage purchases through an inventory system. But what if they wanted to branch out and sell bikes as well? Obviously, they would need a new class for bikes but instead of just repeating shared information like prices and order numbers, we could use an interface which both classes can implement. What is an Interface and Why Should I Use Them? Generally, an interface is defined as a device or system that unrelated things use to interact with each other. For example, your mouse and keyboard are an interface between you and your computer, or your remote control is an interface between you and your TV. In Java, an interface is similar to a class, but unlike classes, it only contains method signatures (the name and parameter types of a method but not its implementation) and constants. You can think of it as a sort of blueprint for a ...

Latest Posts

A Well-Oiled Machine - An Exploration of Concurrent Programming in Java