title: Difference between Throws in method signature and Throw Statements in Java
body: <p>I am trying to make it clear of the difference between <strong>Throws in method signature</strong> and <strong>Throw Statements</strong> in Java.
  Throws in method signature is as following:</p>
  
  <pre><code>public void aMethod() throws IOException{
      FileReader f = new FileReader("notExist.txt");
  }
  </code></pre>
  
  <p>Throw Statements is as following:</p>
  
  <pre><code>public void bMethod() {
      throw new IOException();
  }
  </code></pre>
  
  <p>From my understanding, a <code>throws</code> in method signature is a notification that the method may throw such an exception. <code>throw</code> statement is what actually throw a created object under according circumstances. 
  In that sense, <strong>throws</strong> in method signature should always appear if there exist a <strong>throw</strong> statement in the method.</p>
  
  <p>However, the following code doesn't seem doing so. The code is from the library. My question is why it is happening? Am I understanding the concepts wrong?</p>
  
  <p>This piece of code is a copy from java.util.linkedList. @author Josh Bloch</p>
  
  <pre><code> /**
   * Returns the first element in this list.
   *
   * @return the first element in this list
   * @throws NoSuchElementException if this list is empty
   */
  public E getFirst() {
      final Node&lt;E&gt; f = first;
      if (f == null)
          throw new NoSuchElementException();
      return f.item;
  }
  </code></pre>
  
  <p>Update on the answer:</p>
  
  <p>update 1 : is above code the same as the following? </p>
  
  <pre><code>// as far as I know, it is the same as without throws
  public E getFirst() throws NoSuchElementException {
      final Node&lt;E&gt; f = first;
      if (f == null)
          throw new NoSuchElementException();
      return f.item;
  }
  </code></pre>
  
  <p>update 2 : For checked exception. Do I need to have "throws" in the signature? Yes.</p>
  
  <pre><code>// has to throw checked exception otherwise compile error
  public String abc() throws IOException{
      throw new IOException();
  }
  </code></pre>