Pages

Topics

Tools

↑↓navigate↵openescclose

Java guides

Every published Java guide, newest first, with practical examples you can copy into your own project.

3,965 guides across 14 topics

Topics

Latest Java guides

Diagram showing Java @Target annotation restricting annotation placement to specific Java elements like methods and fields.
Java

Java @Target Annotation: Restricting Where Annotations Apply

Learn how Java's @Target meta-annotation restricts where custom annotations can be applied, with ElementType values, code examples, and common pitfalls.

Java annotationsmeta-annotationcustom annotationsElementType
Diagram showing the three retention policies of a Java annotation: source, class, and runtime, with visibility levels.
Java

Java Retention Annotation: How to Control Annotation Lifecycle

Understand how Java's @Retention meta-annotation controls whether annotations are available in source code, compiled class files, or at runtime, and how to choose the right policy.

Java annotationsReflectionAnnotation processingMeta-annotations
Diagram showing a Java annotation declaration with retention and target attributes.
Java

Java Annotation Declaration: Syntax and Usage

Learn how to declare custom annotations in Java, set retention and target, define elements, and process them with reflection.

JavaAnnotationsReflectionCustom Annotations
Diagram showing a Java annotation being attached to a method symbol and processed by a reflective reader at runtime.
Java

Java Custom Annotation: Syntax, Retention, and Processing

Learn how to create Java custom annotations, control their retention and targets, and process them at runtime with reflection.

annotationsreflectionmetaprogrammingjava
Diagram showing the @SuppressWarnings annotation applied to a Java method to suppress compiler warnings.
Java

Java SuppressWarnings: When and How to Use It

Learn how to use Java's @SuppressWarnings annotation: syntax and placement, common warning names, and when suppressing a compiler warning is justified versus when it hides real problems.

annotationcompiler warningscode qualityunchecked warnings
A Java code editor showing a deprecated method with a warning marker and a replacement suggestion.
Java

Using @Deprecated in Java to Manage API Evolution

Learn how to use Java's @Deprecated annotation to mark outdated APIs, manage compiler warnings, and plan API removal.

Java@DeprecateddeprecationAPI design
Illustration of Java built-in annotations like @Override and @Deprecated with compiler checks
Java

Java Built-In Annotations: Usage and Pitfalls

Learn how Java's built-in annotations @Override, @Deprecated, @SuppressWarnings, @FunctionalInterface, and @SafeVarargs work, including retention, targets, and common mistakes.

Java annotations@Override@Deprecated@SuppressWarnings
Diagram showing Java annotation syntax elements such as @interface, retention, target, and reflection processing.
Java

Java Annotation Syntax: Declaring and Using Annotations

Learn the exact syntax for declaring and using Java annotations, including retention policies, target restrictions, and runtime reflection processing.

JavaAnnotationsReflectionMetadata
Illustration of a Java class blueprint with annotation tags attached and a magnifying glass representing runtime reflection
Java

Java Annotations: Syntax, Retention, and Runtime Use

A practical guide to Java annotations: declaration syntax, retention policies, reflection-based runtime lookup, and common pitfalls when creating custom annotations.

javaannotationsreflectioncustom-annotations
Diagram showing a regex pattern with highlighted capturing groups and named groups in Java
Java

Java Regex Groups: Capturing and Named Groups

Learn how to use capturing groups, named groups, and backreferences in Java regex with practical examples.

regexcapturing groupsnamed groupsPattern