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 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 [...]
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 [...]
Accessibility
4 keywords that affect accessibility are public, protected, package (the default) and private. You probably have seen many times over that package is the default, or default is also the same as package in Java, what it means is just, that you if don’t do anything, don’t put any access keyword in front of either a variable, [...]
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 [...]
Inheritance
Inheritance happens in Java in 2 ways. At the class level via the extends keyword, and the other is the at the interface level, via the implements keyword.
The rules for Java identifiers
Java identifiers includes variable names, method names (methods are functions in Java, there are no sub routines in Java, everything is a method), class names, interface names, package name and enum names – practically everything else that a programmer can define in the Java program. Its very straightforward to define identifiers, we just need to [...]