KOTLIN / NOTES</>↗Kotlin06 May 2025
In Kotlin, you can use both for and while loops to iterate through items. Here is a quick overview of how you can use these loops with examples: 1. Using a for Loop A for loop is used to iterate through a range, array, list, or any iterable. Iterating through a range: for (i in […]
CONCURRENCY / NOTES</>↗Concurrency06 May 2025
The LinkedBlockingQueue in Java is an implementation of the BlockingQueue interface, which is well-suited for implementing the Producer-Consumer problem. It manages a thread-safe queue where producers can add elements and consumers can take elements, with built-in thread synchronization. Here’s how you can implement a basic producer-consumer solution using LinkedBlockingQueue: Example: Producer-Consumer with LinkedBlockingQueue package org.kodejava.util.concurrent; […]
SPRING CORE / NOTES</>↗Spring Core06 May 2025
Spring provides annotations like @Component, @Autowired, and @Qualifier to simplify dependency injection and make applications loosely coupled and modular. Below, we’ll explore these annotations in detail, focusing on their usage and a complete example. 1. @Component Annotation The @Component annotation marks a class as a Spring-managed bean. It is auto-detected during component scanning, and Spring […]
CONCURRENCY / NOTES</>↗Concurrency06 May 2025
Coordinating tasks with Phaser in Java concurrency involves leveraging its powerful synchronization mechanism, especially designed for dynamic scenarios where the number of threads (or parties) may change during execution. The Phaser class found in the java.util.concurrent package provides a flexible and reusable barrier, similar to CyclicBarrier or CountDownLatch, but with added versatility. Key Features of […]
KOTLIN / NOTES</>↗Kotlin05 May 2025
In Kotlin, if expressions are used for decision-making. Unlike some other programming languages, Kotlin’s if is an expression, meaning it returns a value. This makes it more versatile because it can be directly assigned to a variable or used in a function return. Here’s how it works: 1. Basic if expression The simplest usage is […]
KOTLIN / NOTES</>↗Kotlin05 May 2025
In Kotlin, data types like String, Int, and Boolean are fundamental types that are used to work with text, numbers, and logical values respectively. Kotlin provides these types as part of its standard library, and they are straightforward to use. Below is an explanation of how to work with them: 1. String A String in […]