title: Objects of multiple class in java
body: <p>I was revising some of the old school concepts of Java in order to solve one problem . I have written the following code where i am trying the create objects of multiple class in that same classes and calling the methods with those objects from the main.</p>
  
  <pre><code>class a {
      public void display() {
          System.out.println("inside class a");
          a a1= new a();
      }
  }
  
  class b {
      public void display() {
          System.out.println("inside class b");
          b b1= new b();
      }
  }
  
  public class one {
      void display() {
          System.out.println("inside class one");
      }
  
      public static void main(String[] args) {
          one o = new one();
          a1.display();
          b1.display();
          o.display();
      }
  }
  </code></pre>
  
  <p>I am getting object cannot be resolved error. My question is what i need to change to let the above code work. And, do i need to always declare objects inside the main().</p>
  
  <p>Any help will be highly appreciated </p>