java - Is it possible to omit some annotation attributes but not all? -


in java tutorials - annotations part, question 3 (https://docs.oracle.com/javase/tutorial/java/annotations/qande/questions.html), annotation expected used below:

@meal("breakfast", maindish="cereal")

i tried define annotation below not allow above usage.

public @interface meal {     string value();     string maindish(); } 

is possible omit first attribute name question suggested?

no, shortcut works if specify value attribute , nothing else.

otherwise must explicitly write value=, correct version @meal(value = "breakfast", maindish = "cereal")


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -