Any other way to instantiate a "generic array"?

   @Test
   public <E> void testGenericArray() {
      @SuppressWarnings({ "unchecked" })
      E[] elementsE = (E[]) new Object[10];
      E eE = elementsE[1];
      assertNotNull(eE);
     
     
      Object[] elementsO = new Object[10];
      @SuppressWarnings("unchecked")
      E eO = (E) elementsO[2];
      assertNotNull(eO);
   }

Comments