title: Alternative to static Util Classes and Methods in Java
body: <p>Say, I wanted to have this method which takes a Set and formats that set into a string according to some logic. Eg.</p>
  <pre><code>public String formatCustomerSet(final Set&lt;Customer&gt; customers) {
      String result = &quot;&quot;;
      for (Customer customer : customers) {
          result += customer.getFirstName() + &quot; : &quot; + customer.getLastName() + &quot;\n&quot;;
      }
  
      return result;
  }
  </code></pre>
  <p>I am using this code in several classes. Now, where should I put this? I found that Utility classes should be avoided and should not be used?
  <a href="https://lostechies.com/chrismissal/2009/06/01/anti-patterns-and-worst-practices-utils-class/" rel="nofollow noreferrer">https://lostechies.com/chrismissal/2009/06/01/anti-patterns-and-worst-practices-utils-class/</a></p>
  <p>Then, should it be Util class of a specific name like CustomerFormatter which is used, or should we make a OOP class out of it? Which one is recommended and why?</p>