~/ learn/ java-from-zero/ cards/ Declaring custom annotations
1 of 4

Type a custom annotation with two elements and a default

Type a custom annotation with two elements and a default

Answer

public @interface Review { String author(); int priority() default 1; }

author() is required (no default). priority() is optional and defaults to 1. Use @Review(author = "alice") or @Review(author = "alice", priority = 3).

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/8fa37489-d406-4464-b339-c068afe9014a/flashcard utf-8 LF