Browse by Topic

Popular

Latest

Latest Java Posts

A Java code editor with a null reference warning and a NullPointerException stack trace, illustrating null handling.
Java

Java Null Reference: Practical Ways to Avoid NullPointerException

A Java null reference is a common source of NullPointerException. Learn practical techniques—defensive checks, Objects.requireNonNull, Optional, and more—for handling nulls safely.

NullPointerExceptionnull safetyOptionalObjects.requireNonNull
Diagram showing a Java reference variable pointing to an object in heap memory
Java

Java Reference Variables: How Object References Work

java reference variable: Understand how Java reference variables store object addresses, affect assignment and method calls, and interact with null and garbage collect...

Javareference variablesobject referencesmemory management
Illustration of two Java variables referencing the same object, representing reference assignment and aliasing in Java.
Java

Java Object Assignment: Reference vs Value Semantics

Understand how Java object assignment works: assignment copies object references, not the objects themselves. See how aliasing, safe copying, and immutability help avoid unintended shared state.

Java referencesObject aliasingObject copyingImmutability
Diagram showing a Java variable holding a reference to an object on the heap
Java

Java Object Reference: What Variables Actually Hold

Understand how Java object references work: heap storage, pass-by-value behavior, null handling, and equality checks.

JavaObject ReferencesHeap MemoryGarbage Collection
Illustration of Java object initialization sequence showing fields, initializer blocks, and constructor order.
Java

Java Object Initialization: Order and Constructors

Understand how Java initializes objects: field defaults, initializer blocks, constructors, static initialization, and inheritance order.

javaobject-initializationconstructorsinitializer-blocks
Diagram illustrating Java class members: fields, methods, and nested classes
Java

Understanding Java Class Members: Fields, Methods, and More

Learn about Java class members—fields, methods, and nested types—and related class structures: constructors, access modifiers, and static vs instance behavior, with practical examples.

Javafieldsmethodsconstructors
Diagram showing a Java class with a static field shared across multiple instances and threads
Java

Java Static Fields: Lifecycle, Memory, and Thread Safety

java static fields: How Java static fields behave: initialization timing, class loading, memory visibility, thread safety, and when to avoid shared static state.

static-fieldsclass-loadingthread-safetymemory-model
Diagram showing a Java class with instance fields stored per object instance.
Java

Java Instance Fields: Declaration, Initialization, and Access

Understand Java instance fields: declaration, initialization, access, and management of per-object state in Java classes.

JavaInstance FieldsObject-Oriented ProgrammingJava Syntax
Illustration of Java field declaration and access modifiers in a code editor
Java

Java Fields: Declaration, Visibility, and Behavior

java fields: Learn how Java fields work: declaration syntax, access modifiers, static vs instance, initialization, and thread-safety considerations.

JavaFieldsEncapsulationStatic
A blueprint of a car next to a physical car, illustrating the Java class as a template and the object as an instance.
Java

Java Class vs Object: What Actually Differs at Runtime

java class vs object: Understand the real difference between a Java class and an object: compile-time template vs runtime instance, memory layout, and how the JVM trea...

JavaOOPJVMObject Oriented Programming