Java Mechanisms: Compound Assignments, Stream Processing, Memory Leaks, and Serialization

Compound Assignment vs Simple AssignmentThe expression a += b performs implicit type casting, equivalent to a = (type of a)(a + b), which prevents compilation errors when types mismatch. Conversely, a = a + b requires strict type compatibility; otherwise, it results in a compile-time error without automatic downcasting.JDK 8 EnhancementsJDK 8 i ...

Posted on Fri, 06 Nov 2026 16:33:24 +0000 by bsprogs

Common Data Structure Merging Techniques in Java

1. Merge and Deduplicate String Array Elements Given a string array with duplicate elements, split (if needed), deduplicate, and merge. For example: String[] input = {"array", "merge", "thread", "merge"}; Result: [array, merge, thread] /** * Merge and deduplicate a string array (handles split if elements ...

Posted on Mon, 02 Nov 2026 16:22:59 +0000 by daveoliveruk

Java 8 Lambda, Stream, and Date/Time API Deep Dive

Introduction This article focuses on some of the new syntax features in JDK 1.8, specifically Lambda expressions, the Stream API, and the LocalDate date/time API. Lambda What is Lambda? A Lambda expression (lambda expression) is an anonymous function. It is named after lambda calculus in mathematics, directly corresponding to lambda abstractio ...

Posted on Thu, 29 Oct 2026 16:29:18 +0000 by peterj

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

Techniques for Replacing Elements in Java Collections

Using the Collections Class to Replace Elements in a Collection The Collections class is part of the Java Collections Framework and provides numerous static methods for manipulating or returning collection objects. However, the Collections class does not offer a direct method to replace all elements in a collection. You can achieve this by usin ...

Posted on Sun, 09 Aug 2026 16:08:06 +0000 by shoz

Understanding Lambda Expressions in Modern Java

Java 8 introduced lambda expressions as a foundational shift toward functional programming within the language. By enabling developers to pass behavior as data, lambdas eliminate the verbosity of anonymous inner classes and streamline operations that require inline function definitions. Core Syntax and Structure The fundamental anatomy of a lam ...

Posted on Fri, 17 Jul 2026 16:12:31 +0000 by GetPutDelete

Java 8: Key Features and Functional Programming Enhancements

Java 8: Key Features and Functional Programming Enhancements Java 8 (also known as JDK 1.8) represents a significant release in the evolution of the Java programming language. Released by Oracle on March 18, 2014, this version introduced functional programming capabilities, a new JavaScript engine, an enhanced date-time API, and the Stream API ...

Posted on Wed, 08 Jul 2026 17:20:38 +0000 by judgy

Collection Iteration Techniques in Java

Collection iteration refers to the process of accessing each element within a collection and performing operations on them. The Java Collections Framework provides multiple approaches for traversing collections. Traditional Index-Based Loop For List implementations, the classic index-based for loop remains a viable option: List<String> it ...

Posted on Wed, 01 Jul 2026 17:20:06 +0000 by deeem

Working with Java Streams for Data Processing

Streams in Java provide a functional appproach to processing sequences of elements, such as collections or arrays. They support operations like filtering, mapping, and reducing through a pipeline of intermediate and terminal operations, leading to more concise and efficient code. Instantiating Streams From a List A stream can be created from a ...

Posted on Sun, 28 Jun 2026 17:29:04 +0000 by Yanayaya

Transforming Intermediate Stream Types in Java: IntStream, Stream<Integer>, OptionalInt, and Optional<Integer>

IntStream and Stream&lt;Integer&gt; often appear as intermediate phases when working with numeric data in the Java Stream API. Terminal operations like sum, average, min, or max typically yield OptionalInt or Optional&lt;Integer&gt; to safely handle potentially missing values. Understanding how to create these streams, convert b ...

Posted on Mon, 15 Jun 2026 16:25:22 +0000 by Janjan