LANG PACKAGE / NOTES</>↗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 / NOTES</>↗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 / NOTES</>↗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 / NOTES</>↗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, […]
SPRING MVC / NOTES</>↗Spring MVC23 Jul 2025
To configure Spring MVC using a Java-based configuration, you can follow these steps: Enable Spring MVC support by using the @EnableWebMvc annotation. Create a Spring configuration class annotated with @Configuration. Configure the component scanning to detect controllers, services, and other components. Define a ViewResolver bean to map view names to actual views (e.g., JSPs, Thymeleaf […]
SPRING BOOT / NOTES</>↗Spring Boot22 Jul 2025
To implement global exception handling in a Spring application, the @ControllerAdvice annotation is used. It allows you to centralize exception handling across multiple controllers. Below is an example of how you can implement global exception handling with @ControllerAdvice in your application: 1. Define a Global Exception Handler Create a class with the @ControllerAdvice annotation to […]