title: Non static variable cannot be referenced from static context java
body: <p>I'm aware this question has been asked many, many times and I've read loads of answers but I can't get my head around how to fix my problem. Here is my code:</p>
  
  <pre><code>public class Circle
  {
      public int diameter;
      public int xPosition;
      public int yPosition;
      public String color;
  
  
      public Circle()
      {
          diameter = 30;
          xPosition = 20;
          yPosition = 60;
          color = "blue";
      }
  
      public void toString()
      {
          System.out.println("The diameter of the circle is " + Circle.diameter);
          System.out.println("The x position of the circle is " + Circle.xPosition);
          System.out.println("The y position of the circle is " + Circle.yPosition);
          System.out.println("The colour of the circle is " + Circle.color);
      }
  
  
     public static void main(String[] args)
     {
          Circle c1 = new Circle();
          c1.toString();
  
     }
  
  }
  </code></pre>
  
  <p>I did originally fix the issue by changing:</p>
  
  <pre><code>public class Circle
  {
      public int diameter;
      public int xPosition;
      public int yPosition;
      public String color;
  }
  </code></pre>
  
  <p>to</p>
  
  <pre><code>public class Circle
  {
      public static int diameter;
      public static int xPosition;
      public static int yPosition;
      public static String color;
  }
  </code></pre>
  
  <p>Whilst this does work, I feel it's not a good way to do it. I've read something about instance variables but I'm not sure how to do this.</p>
  
  <p>Thanks.</p>