
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
AddAtX Method of the Ennead Tuple in Java
To add value in Ennead class in JavaTuples, you need to use the addAtX() method. Here, X represents the index wherein you need to add the value i.e. for index 2, use addAt2() method. Add the specific value as the parameter value of the method. For example −
addAt2(“John”);
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 −
import org.javatuples.Ennead;
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 add value in Ennead Tuple in Java −
Example
import org.javatuples.Ennead; public class Demo { public static void main(String[] args) { Ennead<String, String, String, String, String, String, String, String, String> e = Ennead.with("Katie", "Tom","Ryan", "Tom","Bradley", "David","Steve", "Brad", "Jacob"); System.out.println("Elements in the Tuple = "+e.addAt0("Newton")); System.out.println("Elements in the Tuple = "+e.addAt2("Stephen")); System.out.println("Elements in the Tuple = "+e.addAt5("Sam")); System.out.println("Elements in the Tuple = "+e.addAt7("Mark")); } }
Output
Elements in the Tuple = [Newton, Katie, Tom, Ryan, Tom, Bradley, David, Steve, Brad, Jacob] Elements in the Tuple = [Katie, Tom, Stephen, Ryan, Tom, Bradley, David, Steve, Brad, Jacob] Elements in the Tuple = [Katie, Tom, Ryan, Tom, Bradley, Sam, David, Steve, Brad, Jacob] Elements in the Tuple = [Katie, Tom, Ryan, Tom, Bradley, David, Steve, Mark, Brad, Jacob]