<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" 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/" > <channel><title>Comments on: Convert ArrayList to Arrays in Java</title> <atom:link href="http://viralpatel.net/blogs/2009/06/convert-arraylist-to-arrays-in-java.html/feed" rel="self" type="application/rss+xml" /><link>http://viralpatel.net/blogs/2009/06/convert-arraylist-to-arrays-in-java.html</link> <description>Tutorials, Java, J2EE, Struts, AJAX, JavaScript, CSS, Web 2.0, MySQL, Articles</description> <lastBuildDate>Wed, 08 Feb 2012 10:36:26 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: ram</title><link>http://viralpatel.net/blogs/2009/06/convert-arraylist-to-arrays-in-java.html/comment-page-1#comment-16542</link> <dc:creator>ram</dc:creator> <pubDate>Tue, 04 Oct 2011 15:07:30 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=1481#comment-16542</guid> <description>thanks</description> <content:encoded><![CDATA[<p>thanks</p> ]]></content:encoded> </item> <item><title>By: Ahmad</title><link>http://viralpatel.net/blogs/2009/06/convert-arraylist-to-arrays-in-java.html/comment-page-1#comment-13501</link> <dc:creator>Ahmad</dc:creator> <pubDate>Fri, 03 Dec 2010 16:49:44 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=1481#comment-13501</guid> <description>Thank you for the great post. Maybe, it&#039;s too late to say this but anyway, let&#039;s try. About the Array to ArrayList conversion, I got error. It cannot recognize the Arrays type. Obviously, I imported the needed classes but even the NetBeans auto-complete couldn&#039;t help to find the reason of the error! By a little bit searching, I figured out that the following code works fine:String[] countries = {&quot;India&quot;, &quot;Switzerland&quot;, &quot;Italy&quot;, &quot;France&quot;}; ArrayList list = new ArrayList(Arrays.asList(countries));Thanks, Ahmad</description> <content:encoded><![CDATA[<p>Thank you for the great post.<br /> Maybe, it&#8217;s too late to say this but anyway, let&#8217;s try.<br /> About the Array to ArrayList conversion, I got error. It cannot recognize the Arrays type.<br /> Obviously, I imported the needed classes but even the NetBeans auto-complete couldn&#8217;t help to find the reason of the error!<br /> By a little bit searching, I figured out that the following code works fine:</p><p>String[] countries = {&#8220;India&#8221;, &#8220;Switzerland&#8221;, &#8220;Italy&#8221;, &#8220;France&#8221;};<br /> ArrayList list = new ArrayList(Arrays.asList(countries));</p><p>Thanks,<br /> Ahmad</p> ]]></content:encoded> </item> <item><title>By: cristian</title><link>http://viralpatel.net/blogs/2009/06/convert-arraylist-to-arrays-in-java.html/comment-page-1#comment-12871</link> <dc:creator>cristian</dc:creator> <pubDate>Tue, 20 Jul 2010 00:23:19 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=1481#comment-12871</guid> <description>thanks!!!!!!</description> <content:encoded><![CDATA[<p>thanks!!!!!!</p> ]]></content:encoded> </item> <item><title>By: Frsutrated</title><link>http://viralpatel.net/blogs/2009/06/convert-arraylist-to-arrays-in-java.html/comment-page-1#comment-12309</link> <dc:creator>Frsutrated</dc:creator> <pubDate>Fri, 19 Mar 2010 08:39:22 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=1481#comment-12309</guid> <description>If your code works then can you please explain this?Test.java:8: generic array creation T [] countries = list.toArray(new T[list.size()]); ^ 1 error</description> <content:encoded><![CDATA[<p>If your code works then can you please explain this?</p><p>Test.java:8: generic array creation<br /> T [] countries = list.toArray(new T[list.size()]);<br /> ^<br /> 1 error</p> ]]></content:encoded> </item> <item><title>By: Hauke</title><link>http://viralpatel.net/blogs/2009/06/convert-arraylist-to-arrays-in-java.html/comment-page-1#comment-9645</link> <dc:creator>Hauke</dc:creator> <pubDate>Sat, 04 Jul 2009 15:24:44 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=1481#comment-9645</guid> <description>If you use an array with the correct size within the toArray method, the result is returned within the provided array. If you use a &quot;new T[0]&quot; another array has to be created, that is thrown away after the type information is read. So it is bad style to use &quot;new T[0]&quot;.</description> <content:encoded><![CDATA[<p>If you use an array with the correct size within the toArray method, the result is returned within the provided array. If you use a &#8220;new T[0]&#8221; another array has to be created, that is thrown away after the type information is read.<br /> So it is bad style to use &#8220;new T[0]&#8220;.</p> ]]></content:encoded> </item> <item><title>By: Dave</title><link>http://viralpatel.net/blogs/2009/06/convert-arraylist-to-arrays-in-java.html/comment-page-1#comment-9604</link> <dc:creator>Dave</dc:creator> <pubDate>Fri, 03 Jul 2009 11:56:59 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=1481#comment-9604</guid> <description>Thanks! It was useful for me! :)</description> <content:encoded><![CDATA[<p>Thanks!<br /> It was useful for me! <img src='http://viralpatel.net/blogs/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p> ]]></content:encoded> </item> <item><title>By: Moe Lavigne</title><link>http://viralpatel.net/blogs/2009/06/convert-arraylist-to-arrays-in-java.html/comment-page-1#comment-9588</link> <dc:creator>Moe Lavigne</dc:creator> <pubDate>Fri, 03 Jul 2009 03:17:15 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=1481#comment-9588</guid> <description>Maybe the following comment would have been better:This is also works: T[] countries = list.toArray(new T[0]);The \&quot;toArray\&quot; method automatically adjusts the size of the target array, but it must be initialized... I just use zero;</description> <content:encoded><![CDATA[<p>Maybe the following comment would have been better:</p><p>This is also works: T[] countries = list.toArray(new T[0]);</p><p>The \&quot;toArray\&quot; method automatically adjusts the size of the target array, but it must be initialized&#8230; I just use zero;</p> ]]></content:encoded> </item> <item><title>By: TinhTruong</title><link>http://viralpatel.net/blogs/2009/06/convert-arraylist-to-arrays-in-java.html/comment-page-1#comment-9585</link> <dc:creator>TinhTruong</dc:creator> <pubDate>Fri, 03 Jul 2009 02:29:48 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=1481#comment-9585</guid> <description>You don&#039;t have to put the list.size() to the new array, just 0 is enough because it just uses the information about the type of the return array, not the size, so the following code will work: T [] countries = list.toArray(new T[0]);</description> <content:encoded><![CDATA[<p>You don&#8217;t have to put the list.size() to the new array, just 0 is enough because it just uses the information about the type of the return array, not the size, so the following code will work:<br /> T [] countries = list.toArray(new T[0]);</p> ]]></content:encoded> </item> <item><title>By: Moe Lavigne</title><link>http://viralpatel.net/blogs/2009/06/convert-arraylist-to-arrays-in-java.html/comment-page-1#comment-9583</link> <dc:creator>Moe Lavigne</dc:creator> <pubDate>Fri, 03 Jul 2009 00:47:26 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=1481#comment-9583</guid> <description>String[] countries = new String[0];List list = new ArrayList(); list.add(&quot;India&quot;); list.add(&quot;Switzerland&quot;); list.add(&quot;Italy&quot;); list.add(&quot;France&quot;);countries = list.toArray(countries);</description> <content:encoded><![CDATA[<p>String[] countries = new String[0];</p><p>List list = new ArrayList();<br /> list.add(&#8220;India&#8221;);<br /> list.add(&#8220;Switzerland&#8221;);<br /> list.add(&#8220;Italy&#8221;);<br /> list.add(&#8220;France&#8221;);</p><p>countries = list.toArray(countries);</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced

Served from: viralpatel.net @ 2012-02-09 09:24:45 -->
