title: How do I use a specific variable of an object that is in another class?
body: <p>I'm trying to modify the toString method. I have an object called 'p' which has 2 doubles as attributes, in this case, 5.0 and 6.0 which are 'x' and 'y' values, respectively.</p>
  
  <p>The brackets, inside the String converter "&lt; Point >", should be printing the "x" of p, the "y" of p, while in the circle it should print the radius. Sure enough printing the radius works, but I'm unsure as to how I'm supposed to specify "x" of p and "y" of p.</p>
  
  <p>Class Circle:</p>
  
  <pre><code>package packageName;
  
  public class Circle {
  
  public Point center;
  public double radius;
  
  public Circle(Point a, double b) {
      this.center = a;
      this.radius = b;
  }
  
      public String toString() {
          String converter = "&lt;Circle(&lt;Point(" + (x of p) + ", " + (y of p) + ")&gt;, " + this.radius + ")&gt;";
          return converter;
      }
  
  
      public static void main(String args []) {
          Point p = new Point(5.0, 6.0);
          Circle c = new Circle(p, 4.0);
          c.toString();
      }
  }  
  </code></pre>
  
  <p>Class Point:</p>
  
  <pre><code>package packageName;
  public class Point{
  
  
  public double x;
  public double y;
  
  public Point(double x, double y) {
      this.x = x;
      this.y = y;
  }
  
  public String toString() {
      String input = "&lt;Point(" + this.x + ", " + this.y + ")&gt;";
      return input;
  
    }
  }
  </code></pre>