BASIC / NOTES</>↗Basic07 Jan 2024
In Java SE 8 and later, you can define static methods on interfaces. A static method is a method associated with the class, not the instance. This means you can call a static method without creating an instance of the class. This feature can be particularly useful when providing utility methods that act on instances […]
2D API / NOTES</>↗2D API07 Jan 2024
Here is a simple Java code for an analog clock using Java 2D features in Swing. Please adjust the code according to your needs. This code will create a new JFrame and continually update it every second with the current time. package org.kodejava.swing; import javax.swing.*; import java.awt.*; import java.util.Calendar; import java.util.GregorianCalendar; public class AnalogClock extends […]
BASIC / NOTES</>↗Basic07 Jan 2024
Default methods are a feature introduced in Java 8, allowing the declaration of methods in interfaces, apart from abstract methods. They are also known as defender methods or virtual extension methods. With the use of default keyword, these methods are defined within the interface and provide a default implementation. This means they can be directly […]
BASIC / NOTES</>↗Basic06 Jan 2024
A Functional Interface in Java is an interface that has exactly one abstract method. Apart from this abstract method, it can include default and static methods. Java 8 introduced the @FunctionalInterface annotation to ensure an interface follows the rules of Functional Interface. It’s optional but good practice to use this annotation. Functional interfaces are extensively […]
CORE API / NOTES</>↗Core API04 Jan 2024
The java.nio.file.Files.lines() method is a Java NIO method used to read the contents of a file line by line. The code snippet will read the file from the specified filePath and print each line to the console. The Files.lines() method returns a Stream of strings, and we use Stream’s forEach method to print each line. […]
BASIC / NOTES</>↗Basic29 Dec 2023
Method references in Java are a feature that was introduced in Java 8. They provide a way to refer to a method without actually executing it. They are often used in conjunction with Java’s functional programming features, such as Streams and Lambdas, where a method to be executed is often expected as a parameter. The […]