JAVA / CATATAN{ }↗Java03 Okt 2025
Text blocks in Java, introduced in Java 15, provide a way to declare multi-line strings in a cleaner and more readable format compared to traditional string concatenation or line breaks (\n). They are enclosed using triple double quotes (""") and support multi-line content without requiring explicit escape characters for formatting. Key Features of Text Blocks […]
JAVA / CATATAN{ }↗Java02 Okt 2025
The String::formatted method in Java is a concise way to format strings using placeholders, similar to the String::format method but with a cleaner syntax. It was introduced in Java 15, and it allows you to replace placeholders in a string with specified values. The syntax of the formatted method is straightforward: String formattedString = "Your […]
JAVA / CATATAN{ }↗Java29 Sep 2025
Using var effectively in local variable declarations in Java is primarily about balancing conciseness and clarity. Below are guidelines, best practices, and tips: When to Use var Obvious Initializer Types Use var when the variable’s initializer makes its type clear: var name = "Alice"; // Clearly a String var age = 25; // Clearly an […]
JAVA / CATATAN{ }↗Java06 Sep 2025
To loop background music in Java using the Clip class from the javax.sound.sampled package, you can use the loop(int count) method of the Clip interface. Setting the count to Clip.LOOP_CONTINUOUSLY makes it loop indefinitely or until the stop() method is called on the Clip. Here is an example to help you achieve this: package org.kodejava.sound; […]
JAVA / CATATAN{ }↗Java04 Sep 2025
Monitoring audio levels in real time is useful for applications like voice recorders, streaming tools, or any app that displays a volume meter. In Java, this is possible using the javax.sound.sampled package, specifically with the TargetDataLine class. In this post, you’ll learn how to: Capture audio input from a microphone Convert it into byte data […]
JAVA / CATATAN{ }↗Java18 Agt 2025
In Java, you can delete files and directories recursively by writing a utility method. The strategy involves: Checking if a file is a directory: If it is, then recursively delete its contents first. Deleting the file or directory: After ensuring a directory is empty, delete it. Here’s an example implementation: Recursive Deletion of Files and […]