title: Java - How to exit a method without return what he is expecting?
body: <p>I've a method similar to the one bellow, where I want to return a private variable of one class only and only if, some conditions are verified. Otherwise I want to exit the method without return anything. I've tried something like the code bellow but I'm afraid that returning null is not a good idea. Are there any way to exit a method like the break keyword works for cycles?</p>
  
  <pre><code>private Classxpto classxpto;
  
  public Classxpto getclassxpto(String abc, Date asd){
          String curr_abc= classxpto.getabc();
          Date curr_asd= classxpto.getasd();
              if("my conditions"){
                  //dont return classxpto
                  return null;
              }else if("my other conditions"){
                  classxpto.setabc(abc);
                  classxpto.setasd(asd);
                  return classxpto;
              }
              return null;    
      }
  </code></pre>