Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Annotations Writing Your Own Annotation Using a Custom Annotation

21,494 Points


How can I tell if it is required based on the information?

1 Answer

Ah, i made this mistake too at my first try. The assertion is: "The element name below is required"

@Secure(role = Role.ADMIN)

To answer this question it is "key" (sorry for the bad joke) to understand, that an element consists of a pair of key and value. Now, the name of this element (key&value) is just, what ever you named the key.

for example: favouriteFood = "Pizza" --> elements name is "favouriteFood"

bestBandEver = "The Dandy Warhols" --> elements name is "bestBandEver"

And by some madness convention some dudes decided that if you key is called "value", you can leave the assignment part and just write down the value of the key named "value".

I hope this helps someone =)