title: Java reduce methods into one?
body: <p>Could somebody tell me if its possible to reduce the amount of methods in my class by doing something like the following to make 2 classes into 1:</p>
  
  <pre><code>public void duplicateEntries(String personName, String entryType) throws CustomException
  {
      for (Entry entry : allEntries)
      {
          if ( entry instanceof entryType)
          {
              if (personName.equalsIgnoreCase(entry.getName()))
              {
                  throw new CustomException("\nAn entry for " + 
                  personName + "already exists. Entry has been cancelled.");
             }
          }
      }
  }
  </code></pre>
  
  <p>Doesnt compile, the compiler reports "cannot find symbol - entryType" on line: </p>
  
  <pre><code>if ( entry instanceof entryType)
  </code></pre>
  
  <p>Original Code:</p>
  
  <pre><code>public void duplicatePersonal(String personName) throws CustomException
      {
          for (Entry entry : allEntries)
          {
              if ( entry instanceof Personal)
              {
                  if (personName.equalsIgnoreCase(entry.getName()))
                  {
                      throw new CustomException("\nAn entry for " + 
                      personName + "already exists. Entry has been cancelled.");
                 }
              }
  
          }
      }
  
      public void duplicateBusiness(String personName) throws CustomException
      {
          for (Entry entry : allEntries)
          {
              if ( entry instanceof Business)
              {
                  if (personName.equalsIgnoreCase(entry.getName()))
                  {
                      throw new CustomException("\nAn entry for " + 
                      personName + "already exists. Entry has been cancelled.");
                 }
              }
          }
      }
  </code></pre>
  
  <p>I know its not minimising my code by much but there is a few methods like this that I could also apply it to.</p>