title: How to get class annotation in java?
body: <p>I have created my own annotation type like this:</p>
  
  <pre><code>public @interface NewAnnotationType {}
  </code></pre>
  
  <p>and attached it to a class:</p>
  
  <pre><code>@NewAnnotationType
  public class NewClass {
      public void DoSomething() {}
  }
  </code></pre>
  
  <p>and I tried to get the class annotation via reflection like this :</p>
  
  <pre><code>Class newClass = NewClass.class;
  
  for (Annotation annotation : newClass.getDeclaredAnnotations()) {
      System.out.println(annotation.toString());
  }
  </code></pre>
  
  <p>but it's not printing anything. What am I doing wrong?</p>