title: exceptions throw or catch and try
body: <p>I'm trying to learn java and I have a little problem with understanding how exceptions work.</p>
  
  <p>When do we need to use throw after a condition?
  As an example </p>
  
  <pre><code>public Ex(String name, String prenom, int age) throws exceptionex  {
      if (name.length() &lt; 3 &amp;&amp; prenom.length() &lt; 3 &amp;&amp; age &lt; 1) throw new exceptionex();
  
          this.age = age;
          this.name = name;
          this.prenom = prenom;
  
  }
  </code></pre>
  
  <p><code>excepetionex</code> is an empty class which extends <code>Exception</code>.</p>
  
  <p>And what is the difference between the previous example and this one?</p>
  
  <pre><code>public Ex(String name, String prenom, int age)   {
      if (name.length() &lt; 3 &amp;&amp; prenom.length() &lt; 3 &amp;&amp; age &lt; 1)
          try {
              throw new exceptionex();
          } catch (exceptionex e) {
              e.printStackTrace();
          }
  
          this.age = age;
          this.name = name;
          this.prenom = prenom;
  
  }
  </code></pre>
  
  <p>And what does <code>printstackTrace</code> exactly do?</p>
  
  <p>Do we always need to create another class if we wanted to customise an exception (<code>exeptionex</code> here ) or we can just use (<code>throw new Exception</code>)? </p>
  
  <p>I googled my questions but i didn't find an answer which i can understand maybe because I'm new or because English is not my native language I need a simple explanation as much as possible please. </p>