UTIL PACKAGE / CATATAN</>↗Util Package29 Jul 2025
In Java, you can generate universally unique identifiers (UUIDs) using the java.util.UUID class. Here’s how you can generate a UUID: Example Code package org.kodejava.util; import java.util.UUID; public class UUIDExample { public static void main(String[] args) { // Generate a random UUID UUID uuid = UUID.randomUUID(); System.out.println("Generated UUID: " + uuid.toString()); } } Explanation The UUID.randomUUID() […]
BASIC / CATATAN</>↗Basic28 Jul 2025
Here’s a step-by-step guide to install Java 21 and set up your development environment: Step 1: Download and Install Java 21 Download JDK 21: Go to the official Oracle Java SE Downloads page or use Adoptium or OpenJDK for an open-source version. Download the JDK 21 version suitable for your system (Windows, macOS, or Linux). […]
LANG PACKAGE / CATATAN</>↗Lang Package27 Jul 2025
In Java, using StringBuilder is a common way to handle efficient string concatenation, especially when working with loops or when you need to concatenate a large number of strings. Unlike String, which is immutable, StringBuilder is mutable and modifies its internal character array without creating new objects, hence improving performance. Here’s how you can use […]
BASIC / CATATAN</>↗Basic26 Jul 2025
In Java, the String.format() method is a convenient way to create formatted strings using placeholders. It allows you to include values such as numbers or strings at specific positions in a string by using format specifiers. Here’s how you can use it: Syntax String.format(String format, Object… args) format: The format string with placeholders. args: The […]
SPRING MVC / CATATAN</>↗Spring MVC25 Jul 2025
In Spring MVC, you can map a request to a controller using the @RequestMapping (or aliases like @GetMapping, @PostMapping, etc.) annotation on a method. These annotations define a specific URL path and HTTP method that the method will handle. Here’s how you can do it: Step-by-Step Instructions: Annotate the Class as a Controller: Use the […]
SPRING BOOT / CATATAN</>↗Spring Boot24 Jul 2025
Testing Spring Boot applications with JUnit and Mockito is a good practice to ensure the correctness and reliability of your application. Below, I’ll present a brief overview of how to write such test cases with explanations and examples. 1. JUnit Basics in Spring Boot Spring Boot provides out-of-the-box support for JUnit through the spring-boot-starter-test dependency, […]