title: Java: how do you pass incomplete information to a class?
body: <p>I am working on learning Java, and have been given an assignment to write a class which recieves a set of variables from another class, and spits out a formatted text. The example file gives the variables twice.</p>
  <p>I have figured out how to do most of this independently, however there is one component which eludes me.
  In the example as mentioned the (call?) is repeated twice, however the first time it is missing a variable which is in the second one:</p>
  <pre><code>Box a = new Box(width, height, depth);
  Box 2 = new Box(width, height, depth, builder);
  </code></pre>
  <p>if i build it to expect the three ints, it throws an error about the string. If i build it to include the string, it throws an error:
  <code>&quot;Box(int, int, int, java.lang.String) in 'Box' cannot be applied to '(int, int, int)'</code></p>
  <p>In the example output, it lists the first one as outputting &quot;null&quot; for the builder section.</p>
  <p>I do not know how to make it accept both inputs, and am open to any suggestions.
  Output code:</p>
  <pre><code>            int width = 33;
              int height = 28;
              int depth = 58;
              String builder = &quot;Lori &quot;;
              Box a = new Box(width,height,depth);
              System.out.println(a.printMe());
              Box b = new Box(width,height, depth,builder);
              System.out.println(b.printMe());
  </code></pre>
  <p>my code:</p>
  <pre><code>public class Box {
      private int width_x;
      private int height_y;
      private int depth_z;
      private String name;
  
  //  constructor?
      public Box(int width,int height,int depth,String builder) {
          width_x = width;
          height_y = height;
          depth_z = depth;
          name = builder;
  //      output test
          System.out.println(width+&quot; &quot;+height+&quot; &quot;+depth+builder);
          System.out.println(width_x +&quot; &quot;+ height_y +&quot; &quot;+ depth_z +name);
      }
  
  
      public String printMe() {
          System.out.println(width_x +&quot; &quot;+ height_y +&quot; &quot;+ depth_z +name);
          return (&quot;Width: &quot;+ width_x +&quot;\n Height: &quot;+ height_y +&quot;\n Depth: &quot;+ depth_z +&quot;\n Built by &quot;+name);
      }
  }
  
  </code></pre>
  <p>And the expected output is:</p>
  <pre><code>  Width: 33
    Height: 28
    Depth: 58
    Built by null
    Width: 33
    Height: 28
    Depth: 58
    Built by Lori
  </code></pre>