Browse by Topic

Popular

Latest

Latest Java Posts

Diagram showing the relationship between hashCode and equals in Java objects.
Java

Java Object hashCode: Contract and Implementation

Understand the Java hashCode contract, why overriding equals requires overriding hashCode, and how to implement it correctly to avoid collection bugs.

hashCodeequalsJava collectionsobject contract
Illustration of two Java objects being compared with equals and hashCode for collection integrity.
Java

Java Object Equals: Contract and Implementation

java object equals: Learn the Java object equals contract, how to implement equals and hashCode correctly, and avoid common pitfalls that break collections.

Javaequals methodhashCodeobject equality
Diagram showing Java Object class methods like equals, hashCode, toString, and clone connected to a central Object node.
Java

Understanding Java Object Class Methods

Learn how Java's Object class methods work: equals, hashCode, toString, clone, wait/notify, and finalize, with override contracts and practical code examples.

Object Classequals and hashCodetoString OverrideJava Concurrency
Diagram showing an inner class instance holding a reference to its outer class instance, with an arrow labeled OuterClass.this
Java

Java OuterClass.this: Accessing the Enclosing Instance

Learn how to use OuterClass.this in Java to access the enclosing instance from inner classes, with practical code examples and common pitfalls.

Javainner classesthis keywordnested classes
Diagram showing an inner class instance holding a reference to its enclosing outer class instance in Java.
Java

Java Inner Class this: Accessing the Outer Instance

java inner class this: Understand how `this` behaves inside Java inner classes and when to use `Outer.this` to reach the enclosing instance.

inner classesthis keywordnested classesJava syntax
Diagram showing an inner class with a reference to its outer class instance and a static nested class without one
Java

Java Nested Class Access Explained

java nested class access: Understand how Java nested classes access outer class members, including visibility rules, static vs inner classes, and common pitfalls.

nested classesinner classesstatic nested classesaccess modifiers
Diagram showing an anonymous class implementing an interface with a method override in Java.
Java

Java Anonymous Class: Syntax, Scope, and Practical Use

Learn how to declare and use anonymous classes in Java, including variable capture, scope, and when to prefer lambdas or local classes.

JavaAnonymous ClassesInner ClassesLambda Expressions
Diagram showing a Java anonymous inner class implementing an interface with a method override, compared to a lambda expression.
Java

Java Anonymous Inner Class: Syntax, Use Cases, Limits

Learn how Java anonymous inner classes work: syntax, variable capture, memory behavior, when to use them, and how they compare with lambdas.

anonymous inner classjava syntaxlambda expressionsvariable capture
Diagram showing a local inner class declared inside a Java method block, with arrows to the enclosing class fields and captured local variables.
Java

Java Local Inner Class: Scope, Syntax, and Use Cases

Java local inner classes are declared inside a method, constructor, or initializer block. See how they access enclosing members and effectively final variables, and when to prefer them over anonymous classes.

JavaLocal Inner ClassScopeAnonymous Class
Diagram comparing Java inner class and static nested class structure and instance relationships.
Java

Java Inner vs Static Nested Class: Key Differences

Understand how Java inner classes and static nested classes differ in instance binding, memory behavior, access to enclosing members, and when to use each.

JavaNested ClassesInner ClassesStatic Nested Classes