<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Maurice Naftalin&#039;s Lambda FAQ</title>
	<atom:link href="https://www.lambdafaq.org/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.lambdafaq.org</link>
	<description>Your questions answered: all about Lambdas and friends</description>
	<lastBuildDate>Tue, 04 May 2021 15:50:56 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.2.38</generator>
	<item>
		<title>Why are static methods split between the Collector interface and the Collectors class?</title>
		<link>https://www.lambdafaq.org/why-are-static-methods-split-between-the-collector-interface-and-the-collectors-class/</link>
		<comments>https://www.lambdafaq.org/why-are-static-methods-split-between-the-collector-interface-and-the-collectors-class/#comments</comments>
		<pubDate>Fri, 27 Mar 2015 22:18:07 +0000</pubDate>
		<dc:creator><![CDATA[smarks]]></dc:creator>
				<category><![CDATA[Design Rationale]]></category>

		<guid isPermaLink="false">http://www.lambdafaq.org/?p=1313</guid>
		<description><![CDATA[<p>In Java 8 it&#8217;s possible to put static methods on interfaces. Why aren&#8217;t all of the Collector-related static methods on the Collector interface? Isn&#8217;t the old pattern of interface X and class Xs (such as Collection/Collections or Path/Paths) obsolete?</p> <p>Static methods on interfaces are indeed a new tool in the toolbox. That means older tools [...]]]></description>
				<content:encoded><![CDATA[<p>In Java 8 it&#8217;s possible to put static methods on interfaces. Why aren&#8217;t all of the Collector-related static methods on the Collector interface? Isn&#8217;t the old pattern of <code>interface X</code> and <code>class Xs</code> (such as <code>Collection</code>/<code>Collections</code> or <code>Path</code>/<code>Paths</code>) obsolete?</p>
<p>Static methods on interfaces are indeed a new tool in the toolbox. That means older tools might get used less often, but not that they&#8217;ll be thrown away. Sometimes it makes sense to put static methods on interfaces, and sometimes it still makes sense to put a bunch of static methods into a separate utility class. This is admittedly somewhat subjective.</p>
<p>In the case of the <code>Collector</code> interface, the two static methods added in Java 8 (the <code>of()</code> overloads) are very general. They allow one to create a new, independent collector from lambda expressions or from any existing method. On the other hand, the static methods on the <code>Collectors</code> class create instances of ready-to-use collectors that are useful for specific purposes. This qualitative difference seemed significant enough to place the ready-to-use collectors into their own class.</p>
<p>In addition, there are three dozen methods that in the <code>Collectors</code> class. Having them all together would have added a lot of clutter to the <code>Collector</code> interface, which is fundamental and cohesive interface that benefits from having relatively few methods.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.lambdafaq.org/why-are-static-methods-split-between-the-collector-interface-and-the-collectors-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
