title: Understanding 'TypeElement' and 'DeclaredType' interface in java
body: <p>One usage of these two interface, is to write annotation processor.</p>
  
  <p>As a java beginner, I find  the level of indirection that is added by these two packages:
  <code>javax.lang.model.element</code> &amp; <code>javax.lang.model.type</code> to provide metadata about java <code>interface</code> and java <code>class</code> confusing.</p>
  
  <p><img src="https://i.stack.imgur.com/XchVN.png" alt="enter image description here">
  .........</p>
  
  <p><img src="https://i.stack.imgur.com/8KkIB.png" alt="enter image description here"></p>
  
  <p>java doc comments say, </p>
  
  <blockquote>
    <p><code>TypeElement</code> represents a <code>class</code> or <code>interface</code> program element. Provides access to information about the type and its members. Note that an <code>enum</code>
    type is a kind of class and an annotation type is a kind of <code>interface</code>.</p>
    
    <p><code>DeclaredType</code> represents a declared type, either a <code>class</code> type or an <code>interface</code> type. This includes parameterized types such as <code>java.util.Set&lt;String&gt;</code> as well as raw types.</p>
  </blockquote>
  
  <p>Difference between the two:</p>
  
  <blockquote>
    <p>While a <code>TypeElement</code> represents a <code>class</code> or <code>interface</code> <em>element</em>, a <code>DeclaredType</code> represents a <code>class</code> or <code>interface</code> <em>type</em>, the latter being a use (or <em>invocation</em>) of the former.</p>
  </blockquote>
  
  <p>How do I differentiate the jargon <em>element</em> from <em>type</em>? For example: How is <code>class</code> <em>element</em> different from <code>class</code> <em>type</em>? Please help me with an example.</p>