How to search for a value in Java Ennead Tuple

Java 8Object Oriented ProgrammingProgramming

<p>To search for a value in Ennead Tuple in Java, use the contains() method. The value you want to search is to be set as the parameter of the method. The contains() method returns a Boolean value i.e TRUE if the value exist, else FALSE. 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 &minus;</p><pre class="result notranslate">import org.javatuples.Ennead;</pre><p><strong>Note</strong> &minus; 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 &minus;</p><p><strong>Steps</strong> &minus; <a href="" target="_blank">How to run JavaTuples program in Eclipse</a></p><p>The following is an example to search for a value in Ennead Tuple in Java &minus;</p><h2>Example</h2><pre class="prettyprint notranslate">import org.javatuples.Ennead; public class Demo { &nbsp; &nbsp;public static void main(String[] args) { &nbsp; &nbsp; &nbsp; Ennead&lt;String, String, String, String, String, String, String, String, String&gt; e = &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Ennead.with(&quot;Katie&quot;, &quot;Tom&quot;,&quot;Ryan&quot;, &quot;Tim&quot;,&quot;Bradley&quot;, &quot;David&quot;,&quot;Steve&quot;, &quot;Brad&quot;, &quot;Jacob&quot;); &nbsp; &nbsp; &nbsp; System.out.println(&quot;Tuple elements = &quot;+e); &nbsp; &nbsp; &nbsp; boolean res = e.contains(&quot;Ryan&quot;); &nbsp; &nbsp; &nbsp; System.out.println(&quot;Does the value exist in the Tuple? &quot;+res); &nbsp; &nbsp;} }</pre><h2>Output</h2><pre class="result notranslate">Tuple elements = [Katie, Tom, Ryan, Tim, Bradley, David, Steve, Brad, Jacob] Does the value exist in the Tuple? True</pre>
Updated on 30-Jul-2019 22:30:25