Tagged articles
5 articles
Page 1 of 1
Cognitive Technology Team
Cognitive Technology Team
Sep 12, 2022 · Fundamentals

Avoiding Memory Leaks with Java Double‑Brace Initialization and Anonymous Inner Classes

This article explains Java's double‑brace initialization trick, shows how it creates anonymous inner classes, demonstrates the resulting memory‑leak and OOM risks, especially with non‑static inner classes, and provides guidelines such as using static inner classes or weak references to avoid these problems.

Anonymous Inner ClassJavaOOM
0 likes · 7 min read
Avoiding Memory Leaks with Java Double‑Brace Initialization and Anonymous Inner Classes
Selected Java Interview Questions
Selected Java Interview Questions
Sep 29, 2020 · Backend Development

Why Java Anonymous Inner Classes Require Final or Effectively Final Variables and How Kotlin Handles Them Differently

The article explains why Java anonymous inner classes can only access final or effectively final variables, shows the compiler‑generated bytecode that enforces this rule, and contrasts it with Kotlin's approach of wrapping primitives to allow modification inside such classes.

Anonymous Inner ClassCompilationEffective Final
0 likes · 6 min read
Why Java Anonymous Inner Classes Require Final or Effectively Final Variables and How Kotlin Handles Them Differently