- 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
Create Decade Tuple from another collection in Java
To create Decade Tuple from another collection in Java, use the fromArray() or the fromCollection() method. Here, we will see how to create a Decade Tuple using the fromCollection() method. This method will allow us to crate a Decade Tuple from a List collection in Java.
Let us first see what we need to work with JavaTuples. To work with Decade class in JavaTuples, you need to import the following package
import org.javatuples.Decade;
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 create Decade Tuple from List collection in Java
Example
import java.util.List; import org.javatuples.Decade; import java.util.*; public class Demo { public static void main(String[] args) { // 10 elements in the List List<String> myList = new ArrayList<String> (); myList.add("Football"); myList.add("Cricket"); myList.add("Tennis"); myList.add("Hockey"); myList.add("Badminton"); myList.add("Archery"); myList.add("Billiards"); myList.add("Cycling"); myList.add("Handball"); myList.add("Squash"); // creating Decade Tuple from List Decade<String, String, String, String, String, String, String, String, String, String> d = Decade.fromCollection(myList); System.out.println("Elements in the Decade Tuple = "); for (Object ele : d) System.out.println(ele); } }
Output
Elements in the Decade Tuple = Football Cricket Tennis Hockey Badminton Archery Billiards Cycling Handball Squash