Implement Octet Class from Septet Class in Java using JavaTuples


At first create Septet and add elements −

Septet<String, String, String, String, String, String, String>
   septet = new Septet<String, String, String, String, String, String, String>(
   "Laptop", "Desktop", "Tablet", "Notebook", "Phone", "Reader", "LCD");

Now, implement Octet from Septet −

Octet<String, String, String, String, String, String, String, String>
octet = septet.add("LED");

Following is an example to implement Octet class from Septet class in Java −

Example

import org.javatuples.Septet;
import org.javatuples.Octet;
public class MyDemo {
   public static void main(String[] args) {
      Septet<String, String, String, String, String, String, String>
         septet = new Septet<String, String, String, String, String, String, String>(
         "Laptop", "Desktop", "Tablet", "Notebook", "Phone", "Reader", "LCD");
      System.out.println("Septet elements = " + septet);
      Octet<String, String, String, String, String, String, String, String>octet = septet.add("LED");
      System.out.println("Octet (implemented from Septet) = " + octet);
   }
}

Output

Septet elements = [Laptop, Desktop, Tablet, Notebook, Phone, Reader, LCD]
Octet (implemented from Septet) = [Laptop, Desktop, Tablet, Notebook, Phone, Reader, LCD, LED]

Updated on: 20-Sep-2019

48 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements