• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ElementType.TYPE versus ElementType.FIELD

 
Sudarshan Sreenivasan
Ranch Hand
Posts: 188
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The below i have borrowed from the following website annotations tutorials

@Target(ElementType.TYPE)�can be applied to any element of a class
@Target(ElementType.FIELD)�can be applied to a field or property


My understanding of the above is such that
A annotation marked with ElementType.TYPE can also be applied to a field in the class

However annotation marked as a ElementType.FIELD cannot be applied to type(Custom defined field) in the class.

Is this correct ??

What exactly is a field or property (explain with an example please)

My understanding of a TYPE is that it should be a class rather than a primitive. (Is this correct )
Thanks
[ September 24, 2008: Message edited by: sid sree ]
 
Sergio Tridente
Ranch Hand
Posts: 329
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Accordingly to the javadocs:

ElementType.TYPE: Class, interface (including annotation type), or enum declaration
ElementType.FIELD: Field declaration (inlcudes enum constants)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic