title: How to avoid repetition when overriding a method?
body: <p>For example I have a parent class: </p>
  
  <pre><code>public class Parent {
      public String getString() {
          return "";
      }
  }
  </code></pre>
  
  <p>And a group of subclasses override getString() and return the same result:</p>
  
  <pre><code>public class Child1 extends Parent {
      @Override
      public String getString() {
          return "return a string";
      }
  }
  
  public class Child2 extends Parent {
      @Override
      public String getString() {
          return "return a string";
      }
  }
  
  public class Child3 extends Parent {
      @Override
      public String getString() {
          return "return a string";
      }
  }
  </code></pre>
  
  <p>Another group of subclasses return the same result too:</p>
  
  <pre><code>public class Child4 extends Parent {
      @Override
      public String getString() {
          return "return nothing";
      }
  }
  
  public class Child5 extends Parent {
      @Override
      public String getString() {
          return "return nothing";
      }
  }
  
  public class Child6 extends Parent {
      @Override
      public String getString() {
          return "return nothing";
      }
  }
  </code></pre>
  
  <p>So the result is, I have to write the same implementation for overriding getString() many time. Is there any better way than this ?
  Thank you very much for any reply.</p>