My Blog

My WordPress Blog

My Blog

My WordPress Blog

Unit Class

Introduction The org.javatuples.Unit class represents a Tuple with single element. Class declaration Following is the declaration for org.javatuples.Unit class − Learn Java in-depth with real-world projects through our Java certification course. Enroll and become a certified expert to boost your career. Class constructors Sr.No. Constructor & Description 1 Unit(A value0)This creates a Unit Tuple. Class Methods Sr.No. Method & Description 1 Pair […]

Checking Elements

Each tuple provides utility methods to check their elements in similar fashion as collection. Example Let’s see JavaTuples in action. Here we’ll see how to check elements in a tuple. Create a java class file named TupleTester in C:\>JavaTuples. File: TupleTester.java Verify the result Compile the classes using javac compiler as follows − Now run the TupleTester to […]

Iteration

Each tuple implements Iterable interface and can be iterated in similar fashion as collection. Example Let’s see JavaTuples in action. Here we’ll see how to iterate tuples. Create a java class file named TupleTester in C:\>JavaTuples. File: TupleTester.java Verify the result Compile the classes using javac compiler as follows − Now run the TupleTester to see the result […]

Conversion

Tuple to List/Array A tuple can be converted to List/Array but at cost of type safety and converted list is of type List<Object>/Object[]. Collection/Array to Tuple A collection can be converted to tuple using fromCollection() method and array can be converted to tuple using fromArray() method. If size of array/collection is different than that of […]

Remove Elements

A tuple has removeAtX() methods to remove value at particular index. For example Triplet class has following methods. Removing an element returns a new tuple. Example Let’s see JavaTuples in action. Here we’ll see how to remove value in a tuple. Create a java class file named TupleTester in C:\>JavaTuples. File: TupleTester.java Verify the result Compile […]

Set Values

A tuple has setAtX() methods to set value at particular index. For example Triplet class has following methods. Feature Example Let’s see JavaTuples in action. Here we’ll see how to set values in a tuple using various ways. Create a java class file named TupleTester in C:\>JavaTuples. File: TupleTester.java Verify the result Compile the classes using javac compiler […]

Get Values

A tuple has getValueX() methods to get values and getValue() a generic method to get value by index. For example Triplet class has following methods. Feature Example Let’s see JavaTuples in action. Here we’ll see how to get values from a tuple using various ways. Create a java class file named TupleTester in C:\>JavaTuples. File: TupleTester.java […]

Create Tuples

A tuple using JavaTuple classes can be created using multiple options. Following are the examples − Using with() Methods Each tuple class has a with() method with corresponding parameters. For example − Using Constructor Each tuple class has a constructor with corresponding parameters. For example − Learn Java in-depth with real-world projects through our Java certification course. Enroll […]

Scroll to top