The following code: for (CharSequence cs: elements) { joiner.add(cs); }
Can be replaced with: elements.forEach(joiner::add); This would have the minor benefit of making it safe to use String.join with synchronized collections without requiring a client side lock. There are likely other opportunities like this in the JDK. Also, with the addition of forEach on Iterable, and Predicate in Java 8, the following design FAQ is outdated. https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/util/doc-files/coll-designfaq.html#a6 <https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/util/doc-files/coll-designfaq.html#a6> Thanks, Don