title: Error: No enclosing instance of type Main is accessible. Must qualify the allocation with an enclosing instance of type Main (e.g. x.new A() wh
body: <p>My code does not work. I  get the following error:</p>
  
  <blockquote>
    <p>No enclosing instance of type Main is accessible. Must qualify the allocation with an enclosing instance of type Main (e.g. x.new A() where x is an instance of Main).</p>
  </blockquote>
  
  <p>You see my code in the following:</p>
  
  <pre><code>class Main {
  
  public class Room {
      @Override
      public int hashCode() {
          final int prime = 31;
          int result = 1;
          result = prime * result + etage;
          result = prime * result + gebäude;
          result = prime * result + raumnummer;
          return result;
      }
  
      @Override
      public boolean equals(Object obj) {
          if (this == obj)
              return true;
          if (obj == null)
              return false;
          if (getClass() != obj.getClass())
              return false;
          Room other = (Room) obj;
          if (etage != other.etage)
              return false;
          if (gebäude != other.gebäude)
              return false;
          if (raumnummer != other.raumnummer)
              return false;
          return true;
      }
  
      public int gebäude;
      public int etage;
      public int raumnummer;
  
      public Room(int gebäude, int etage, int raumnummer) {
          super();
          this.gebäude = gebäude;
          this.etage = etage;
          this.raumnummer = raumnummer;
      }
  
      @Override
      public String toString() {
          String s = String.format("%2s-%s.%02d", this.gebäude, this.etage, this.raumnummer);
          return s;
      }
  }
  
  public static void main(String[] args) {
      Room office = new Room(17, 0, 10);
      Room lecture = new Room(2, 0, 10);
      Room lab = new Room(18, 1, 1);
  
      System.out.println(office);  // =&gt; "17-0.10"
      System.out.println(lecture); // =&gt; " 2-0.10"
      System.out.println(lab);     // =&gt; "18-1.01"
  }
  </code></pre>
  
  <p>}</p>