title: Generic Array Creation
body: <p>Here is the code I'm using</p>
  
  <pre><code>public class aClass&lt;T&gt; {
  
      private T[] elements;
  
      public aClass(T[] elements) {
          this.elements = elements;
      }
  
      public void doSomething() {
          T[] newArray = (T[]) new Object[5];
          ...
      }
  
  }
  </code></pre>
  
  <p>I've seen people saying that creating an array like this is a bad idea, due to it being not type safe. However, every time I use it, I have no problems with it. When would creating an array like this cause a problem?</p>
  
  <p>Thanks</p>