title: How does Validation.Exception in Java work?
body: <p>I am quite new to Java and I am struggeling to understand Exceptions.
  In an Excercise I was supposed to implement the Interface "exceptions.excercise.Validator" in the class "ValidatorImpl" and the Method "User#validate".
  I am struggeling to understand what exactly is happening in these lines of codes and I would really appreciate it, if somebody could help me :):</p>
  
  <p>I am not sure if you need the whole java project to understand the code but here's what I don't really understand:
  *In <em>User.java</em></p>
  
  <pre><code>public void validate() throws UserException {
      Validator valid = new ValidatorImpl();
  
      try {
          valid.validateAge(this.getAge());
          valid.validateEmailWithRuntimeException(this.getEmail());
      } catch (ValidationException e) {
          throw new UserException("age is incorrect", e);
      } catch(ValidationRuntimeException e ) {
          throw new UserException("mail is incorrect", e);
      }
  }
  </code></pre>
  
  <p><em>In ValidatorImpl.java</em>:
  package exceptions.excercise;</p>
  
  <p>public class ValidatorImpl implements Validator {</p>
  
  <pre><code>@Override
  public void validateAge(int age) throws ValidationException {
  
      if ((age &lt; 0) || (age &gt; 120)) {
          throw new ValidationException(age + "not betweeon 0 and 120");
      }
  }
  
  @Override
  public void validateEmailWithRuntimeException(String email) {
  
      if (email == null) {
          throw new ValidationRuntimeException("email is null");
      }
      if (!email.contains("@")) {
          throw new ValidationRuntimeException("email must contain @sign");
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I know this is quite a lot.
  Thank you if you read all of this :)</p>