Sorting and Comparing Java Collections: A Deep Dive into Comparator and Comparable
The Comparable Interface
Comparable is a core Java interface used to define the natural ordering of objects of a custom class. Any class that implements this interface must override the compareTo() method, which encodes the comparison logic between the current object and another instance of the same class.
Usage Example
Classes that implement C ...
Posted on Fri, 18 Sep 2026 16:19:10 +0000 by manamino
Implementing Custom Sorting Strategies in Java Collections
Implementing the Comparable interface establishes a natural ordering for a class. When a domain object overrides compareTo, standard collection utilities can sort instances without external configuration.
import java.util.ArrayList;
import java.util.List;
public class NaturalOrderingDemo {
public static void main(String[] args) {
L ...
Posted on Thu, 17 Sep 2026 16:32:48 +0000 by Eiolon
Java Collections Framework: A Comprehensive Guide to Data Structures
Java Collections Framework Overview
List Interface Implementations
ArrayList
ArrayList is a dynamic array-based implementation of the List interface. It provides fast random access but slower insertions/deletions in the middle.
Characteristics:
Resizable array implementation
O(1) time complexity for get operations
Amortized O(1) for append ...
Posted on Wed, 16 Sep 2026 16:26:21 +0000 by linkin
Python Collections Module: Specialized Container Types
Collections Module Overview
The collections module provides specialized container alternatives to Python's built-in containers like list, dict, set, and tuple. Key components include:
namedtuple: Creates tuple subclasses with named fields
deque: Double-ended queue for efficient appends/pops
Counter: Dictionary subclass for counting hashable ob ...
Posted on Mon, 14 Sep 2026 16:35:40 +0000 by L
Passing Collection Parameters in Java HTTP GET Requests
In Java, two common methods exist for passing collection parameters via HTTP GET requests: URL parameter concatenation and using the @RequestParam annotation. Each approach serves different scenraios.
URL Paramter Concatenation
This method converts collections into comma-separated strings appended to URLs. Suitable for simple data structures.
/ ...
Posted on Mon, 14 Sep 2026 16:15:06 +0000 by bishnu.bhatta
Processing Collections with Java Streams
Understanding Streams in Java
Introduction and Stream Utility
Consider a scenario where you need to filter and process a collection of strings. Given a list of names, the task are: extract names starting with a specific prefix, further filter those by length, and finally display the results.
Example using a traditional approach:
import java.uti ...
Posted on Thu, 10 Sep 2026 16:12:52 +0000 by jemrys
ArrayList Internal Implementation and Capacity Management
Understanding ArrayList's Core Implementation
Analyzing source code effectively requires focusing on specific questions rather than reading sequentially. For ArrayList, a fundamental Java collection class, several key aspects merit examination:
How does ArrayList handle capacity expansion when adding elements?
What specific implementation deta ...
Posted on Thu, 03 Sep 2026 16:45:52 +0000 by qads
Java Core Mechanisms: From Exception Handling to Logging Configuration
Exception Handling
Understanding Exceptions
An exception represents an abnormal condition that arises during program execution. Java groups exceptions into checked and unchecked categories, enabling structured error management.
Custom Exception Classes
Applications often require specific exception types beyond the standard library. Two variants ...
Posted on Wed, 02 Sep 2026 16:20:19 +0000 by mybluehair
Exploring Advanced Java: Lambdas, Collections, Streams, I/O, Multithreading, Networking, and Reflection
Lambda Expressions
Lambda expressions enable concise representation of single-method interfaces. They eliminate boilerplate anonymous inner classes.
// Sorting an integer array
Integer[] values = {4, 7, 1, 9, 3};
// Anonymous inner class
Arrays.sort(values, new Comparator<Integer>() {
@Override
public int compare(Integer a, Integ ...
Posted on Wed, 26 Aug 2026 16:38:26 +0000 by catchy
Efficient Data Processing with Java 8 Stream API
The Stream API introduced in Java 8 revolutionized how developers handle collections. This functional approach enables writing cleaner, more expressive code when processing sequences of elements from various sources such as collections, arrays, or I/O resources. Unlike traditional loops, Stream operations do not modify the underlying data sourc ...
Posted on Sat, 15 Aug 2026 16:52:11 +0000 by Azkoyen