Built-in & Custom Annotations in Java
From the Java cheat sheet · Annotations · verified Jul 2026
Built-in & Custom Annotations
The common annotations plus a custom one read via reflection.
java
// Quick Reference
@Override // method overrides a supertype method
@Deprecated // API is obsolete
@FunctionalInterface // exactly one abstract method
@SuppressWarnings("unchecked")💡 @Override is optional but lets the compiler catch signature typos in overrides.
⚡ @Retention(RUNTIME) is required to read an annotation via reflection at runtime.
📌 @Target restricts where an annotation may be applied (METHOD, TYPE, FIELD, ...).
🟢 Annotation elements look like methods; value() is special and can be set positionally.
annotationsreflection