Create Ennead Tuple from another collection in Java

Java 8Object Oriented ProgrammingProgramming

<p>To create Ennead Tuple from another collection, use the fromCollection() method. Using this method, create an Ennead Tuple using List collection. Let us first see what we need to work with JavaTuples. To work with Ennead class in JavaTuples, you need to import the following package.</p><pre class="result notranslate">import org.javatuples.Ennead;</pre><p><strong>Note</strong> Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project -&gt; Properties -&gt; Java Build Path -&gt; Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run JavaTuples.</p><p><strong>Steps:</strong> <a href="https://www.tutorialspoint.com/how-to-run-javatuples-program-in-eclipse" target="_blank">How to run JavaTuples program in Eclipse</a></p><p>The following is an example to create Ennead Tuple from another collection in Java.</p><h2>Example</h2><pre class="prettyprint notranslate">import org.javatuples.Ennead; import java.util.*; public class Demo { &nbsp; &nbsp;public static void main(String[] args) { &nbsp; &nbsp; &nbsp; List&lt;String&gt; myList = new ArrayList&lt;String&gt;(); &nbsp; &nbsp; &nbsp; myList.add(&quot;Accessories&quot;); &nbsp; &nbsp; &nbsp; myList.add(&quot;Shirt&quot;); &nbsp; &nbsp; &nbsp; myList.add(&quot;Trousers&quot;); &nbsp; &nbsp; &nbsp; myList.add(&quot;Furniture&quot;); &nbsp; &nbsp; &nbsp; myList.add(&quot;Smart Wearable Tech&quot;); &nbsp; &nbsp; &nbsp; myList.add(&quot;Smart Home Automation&quot;); &nbsp; &nbsp; &nbsp; myList.add(&quot;Books&quot;); &nbsp; &nbsp; &nbsp; myList.add(&quot;Stationery&quot;); &nbsp; &nbsp; &nbsp; myList.add(&quot;Instrument&quot;); &nbsp; &nbsp; &nbsp; Ennead&lt;String, String, String, String, String, String, String, String, String&gt; e = Ennead.fromCollection(myList); &nbsp; &nbsp; &nbsp; System.out.println(&quot;Elements in the Ennead Tuple = &quot;); &nbsp; &nbsp; &nbsp; for (Object ele : e) System.out.println(ele); &nbsp; &nbsp;} }</pre><h2>Output</h2><pre class="result notranslate">Elements in the Ennead Tuple = Accessories Shirt Trousers Furniture Smart Wearable Tech Smart Home Automation Books Stationery Instrument</pre>
raja
Updated on 30-Jul-2019 22:30:25

Advertisements