title: How to declare an interface inside class method?
body: <p>I wrote the following class:</p>
  <pre><code> public class Dog {
      private int age = 9;
      private String name = &quot;newton&quot;;
      public String bark() {
          return &quot;&quot; + name+ &quot; &quot; + &quot;bark&quot;;
      }
      public void assignCallback(ClassThatGetsCallback classThatGetCallback) {
          public interface Callback {
              public void callbackMethod();
          }
  
          classThatGetCallback.functionThatGetsCallback(new Callback() 
          {
              public void callbackMethod() {
                  age =8;
                  System.out.println(age);
                  System.out.println(bark());
              }
          }); 
      }
  }
  </code></pre>
  <p>I declared an interface with the name <strong>Callback</strong> inside the method <strong>assignCallback</strong>.
  When trying to compile i'm getting the following error message:</p>
  <blockquote>
  <p>Dog.java.13: error: illegal start or expression
  public interface callback</p>
  </blockquote>
  <p>What is the problem with my code?</p>