title: Different form of method overloading
body: <p>I have seen similar questions to this one. However, I could not find an exact answer to this. I want to know the best approach of following ones based on circumstances. Please explain advantages and disadvantages of case 1 and case 2?.</p>
  
  <p>Case 1 :</p>
  
  <pre><code>  public class Test {
  
      public void method1(String s) {
          System.out.println("String s");
      }
  
      public void method1(String s, String a) {
          System.out.println("String s" + "String a");
      }
  }
  </code></pre>
  
  <p>Case 2:</p>
  
  <p>I wrote the code in following way. It is a simple logic, I wanted to demonstrate only the implementation </p>
  
  <pre><code>public class Test {
  
      public void method1(String s) {
          new Test().methodImpl(s,null);
      }
  
      public void method1(String s, String a) {
          new Test().methodImpl(s,a);
      }
  
      public void methodImpl(String x , String y){
          if(y!=null){
              System.out.println("String s" + "String a");
          }else if(y==null){
              System.out.println("String s");
          }
      }
  }
  </code></pre>