title: How to create a custom exception type in Java?
body: <p>I would like to create a custom exception in Java, how do I do it?</p>
  
  <pre><code>...
  
  try{
  
  ...
  
  String word=reader.readLine();
  
  if(word.contains(" "))
    /*create custom exception*/
  
  }
  catch(){
  </code></pre>
  
  <p>When I create my custom exception with <code>throw new...</code>, I obtain the error <code>unreported exception...must be caught or declared to be thrown</code> </p>