How-to articles, tricks, and solutions about INTERFACE

How should I have explained the difference between an Interface and an Abstract class?

An interface is a collection of abstract methods that define a set of functions that a class must implement.

Implements vs extends: When to use? What's the difference?

In Java, the extends keyword is used to inherit from a superclass, and the implements keyword is used to implement an interface. Here are the key differences between the two:

Interface or an Abstract Class: which one to use?

An interface defines a set of methods that a class must implement, but does not provide any implementation for those methods.

Java Pass Method as Parameter

To pass a method as a parameter in Java, you can use a functional interface and a lambda expression.

Type List vs type ArrayList in Java

In Java, List is an interface that defines a list data structure, while ArrayList is a class that implements the List interface.

Why are interface variables static and final by default?

In Java, interface variables are static and final by default because that is how they are defined in the Java Language Specification (JLS).