- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Fetch the value from an Octet Tuple in Java
To fetch the value from an Octet Tuple, use the getValueX() method. Here X is the index for which you want the value.
For example, to fetch the 5th element i.e. 4th index, use the getValueX() method as −
getValue(4);
Let us first see what we need to work with JavaTuples. To work with Octet class in JavaTuples, you need to import the following package −
import org.javatuples.Octet;
Note − Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project -> Properties -> Java Build Path -> Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run JavaTuples −
Steps − How to run JavaTuples program in Eclipse
The following is an example to fetch the value from Octet Tuple in Java −
Example
import org.javatuples.Octet; import java.util.*; public class Demo { public static void main(String[] args) { String[] strArr = {"laptop", "desktop","mobile", "tablet","monitor", "LCD","LED", "OLED"}; Octet<String, String, String, String, String, String, String, String> oc = Octet.fromArray(strArr); System.out.println("Result = " + oc); // index 0 System.out.println("Value 1 = "+oc.getValue0()); // index 1 System.out.println("Value 2 = "+oc.getValue1()); // index 2 System.out.println("Value 3 = "+oc.getValue2()); // index 3 System.out.println("Value 4 = "+oc.getValue3()); } }
Output
Result = [laptop, desktop, mobile, tablet, monitor, LCD, LED, OLED] Value 1 = laptop Value 2 = desktop Value 3 = mobile Value 4 = tablet
- Related Articles
- Create Octet Tuple from an array in Java
- Fetch the value from Decade Tuple in Java
- Fetch the value from a LabelValue Tuple in Java
- Search for a value in Java Octet Tuple
- Create Octet Tuple from another collection in Java
- How to fetch the value from a KeyValue Tuple in Java?
- How to add a value in Octet Tuple in Java
- Create Octet Tuple from a List collection in Java
- Iterate through Octet Tuple in Java
- Fetch the value in a Java Pair Class Tuple
- Fetch the key from a KeyValue Tuple in Java
- How to create Octet Tuple in Java?
- The setAtX() method of the Octet Tuple in Java
- The addAtX() method of the Octet Tuple in Java
- The contains() method of the Java Octet Tuple

Advertisements