<?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 &#187; Fundamentals</title>
	<atom:link href="https://www.lambdafaq.org/category/fundamentals/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>What are constructor references?</title>
		<link>https://www.lambdafaq.org/what-are-constructor-references/</link>
		<comments>https://www.lambdafaq.org/what-are-constructor-references/#comments</comments>
		<pubDate>Mon, 01 Oct 2012 07:45:08 +0000</pubDate>
		<dc:creator><![CDATA[naftalin]]></dc:creator>
				<category><![CDATA[Fundamentals]]></category>

		<guid isPermaLink="false">http://www.lambdafaq.org/?p=290</guid>
		<description><![CDATA[<p>In the same way that method references are handles to existing methods, constructor reference are handles to existing constructors. Constructor references are created using syntax similar to that for method references, but with the method name replaced with the keyword new. For example:</p> ArrayList::new File::new <p>If the constructor is generic, type arguments can be explicitly [...]]]></description>
				<content:encoded><![CDATA[<p>In the same way that method references are handles to existing methods, constructor reference are handles to existing constructors.  Constructor references are created using syntax similar to that for method references, but with the method name replaced with the keyword <code>new</code>. For example:</p>
<pre><code>    ArrayList::new
    File::new
</code></pre>
<p>If the constructor is generic, type arguments can be explicitly declared before <code>new</code>:</p>
<pre><code>    interface Factory&lt;T> { T make(); }
    Factory&lt;ArrayList&lt;String>> f1 = ArrayList::&lt;String>new;
</code></pre>
<p>As with method references, the choice between overloaded constructors is made using the target type of the context. For example, the second line of the following code <span class="glossary-term" onmouseover="TagToTip('map', FOLLOWMOUSE, false, STICKY, true, DURATION, 5000)">maps</span> the <code>Integer(String)</code> constructor on to each element of <code>strList</code> (and then adds them all into a new collection using a collector): </p>
<pre><code>    List&lt;String> strList = Arrays.asList("1","2","3");
    List&lt;Integer> intList = strList.stream().map(Integer::new).collect(Collectors.toList());
</code></pre>
<p><span id="map">The <code>map</code> method of <code>Iterable</code> applies its argument (in this case the constructor for <code>Integer</code>)<br />to each element of the receiver in turn, creating a new <code>Iterable</code> to hold the results.</span></p>
]]></content:encoded>
			<wfw:commentRss>https://www.lambdafaq.org/what-are-constructor-references/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
