title: Java- How to fail a program if some condition does match?
body: <p>I have a condition where i am checking for something. I want to fail this program if that condition does not match. How can i fail a program or throw an exception if it is does not match a condition. </p>
  
  <p>what i did</p>
  
  <pre><code>String workStream="Default";
  String workSteam2;
  
  for(String s : s1){
      if(s.equals(workStream)){
          workSteam2=workStream;
      }else{
          throw new Exception();
      }
  }
  </code></pre>