title: Printing an array with no elements?
body: <p>I have a few questions. I am working on a homework assignment but came across a few confusing things. (I am taking an introductory class, sorry for the mistakes.)</p>
  
  <blockquote>
    <p>Implement a class that takes an integer array and an  int x as its
    size. Create a method inside the class that creates a new array whose
    length is one greater than data’s length. Then create a method to copy
    all data’s elements into the new array and add the value of x into the
    last element of the array. Create a method to return all the integers
    in the new array.</p>
  </blockquote>
  
  <p>Here's what I have</p>
  
  <pre>package taskone;
  
  import java.util.*;
  
  class Arrayplus1 {
  
      int x;
      int data[];
  
      void example(int x) {
          this.x = x+1;
          this.data= new int[x];
      }
  
      void increaseSizeOfArray(int incrementSize) {
              int copiedArray[] = Arrays.copyOf(data, data.length + incrementSize);
              data = copiedArray;
  
      }
  
      void printall() {
          System.out.println(Arrays.toString(data));
      }
  }
  
  public class TaskOne {
  
      public static void main(String[] args) {
          example task = new example();
          task.printall();
      }
  
  }
  </pre>
  
  <p>This simply returns null.</p>
  
  <p>My question is the last bit of the task above. "Create a method to return all the integers in the new array." </p>
  
  <p>How is this possible when I did not include any elements in my array? I am trying to follow the assignment guidelines. Thanks.</p>