title: What is a Scalar type and why is it riskier to suppress an unchecked cast to an array type than to a scalar type?
body: <p>From Effective Java Item 26  <strong>Favour Generic types</strong></p>
  
  <blockquote>
    <p>All other things being equal, it is riskier to suppress an unchecked
    cast to an array type than to a scalar type, which would suggest the
    second solution. But in a more realistic generic class than Stack, you
    would probably be reading from the array at many points in the code,
    so choosing the second solution would require many casts to E rather
    than a single cast to E[],which is why the first solution is used more
    commonly [Naftalin07, 6.7].</p>
  </blockquote>
  
  <p>What does the author mean by <code>scalar type</code> here and what is he trying to convey here ? What is option 1 considered more dangerous than option 2?</p>
  
  <p>The code :</p>
  
  <pre><code>// The elements array will contain only E instances from push(E).
  // This is sufficient to ensure type safety, but the runtime
  // type of the array won't be E[]; it will always be Object[]!
  @SuppressWarnings("unchecked") 
  public Stack() {
    elements = (E[]) new Object[DEFAULT_INITIAL_CAPACITY];
  }
  </code></pre>
  
  <p>VS</p>
  
  <pre><code>// Appropriate suppression of unchecked warning
  public E pop() {
    if (size == 0)
      throw new EmptyStackException();
    // push requires elements to be of type E, so cast is correct
     @SuppressWarnings("unchecked") E result = 
     (E) elements[--size];
     elements[size] = null; // Eliminate obsolete reference
     return result;
  }                    
  </code></pre>