CORE API / CATATAN</>↗Core API08 Jan 2024
The BufferedReader.lines() method is a Java 8 method that returns a Stream, each element of which is a line read from the BufferedReader. This allows you to perform operations on each line with Java’s functional programming methods. Returning a Stream of strings makes the BufferedReader.lines() method very efficient in terms of memory usage when working […]
JAVA 8 / CATATAN</>↗Java 807 Jan 2024
The Java Stream API is a powerful tool introduced in Java 8. It is designed to process data in a declarative way. More specifically, it makes it easy to process sequences of data elements, such as collections or arrays. Here are some key points about Java Stream API: Non-mutating: Operations on streams do not mutate […]
BASIC / CATATAN</>↗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 / CATATAN</>↗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 / CATATAN</>↗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 / CATATAN</>↗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 […]