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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -