Implement Sextet Class from Quintet Class in Java using JavaTuples

Java 8Object Oriented ProgrammingProgramming

At first create Quintet class and add some elements −

Quintet<String, String, String, String, String>
   quintet = new Quintet<String, String, String, String, String>("ReactJS", "C#", "CSS", "JavaScript", "jQuery");

Now, implement Sextet from Quintet class −

Sextet<String, String, String, String, String, String>sextet = quintet.add("ExpressJS");

Following is an example to implement Sextet class from Quintet class in Java −

Example

import org.javatuples.Quintet;
import org.javatuples.Sextet;
public class MyDemo {
   public static void main(String[] args) {
      Quintet<String, String, String, String, String>
         quintet = new Quintet<String, String, String, String, String>(
         "ReactJS", "C#", "CSS", "JavaScript", "jQuery");
      System.out.println("Quintet elements = " + quintet);
      Sextet<String, String, String, String, String, String>sextet = quintet.add("ExpressJS");
      System.out.println("Sextet elements (implemented from Quintet class) " + sextet);
   }
}

Output

Quintet elements = [ReactJS, C#, CSS, JavaScript, jQuery]
Sextet elements (implemented from Quintet class) [ReactJS, C#, CSS, JavaScript, jQuery, ExpressJS]
raja
Published on 24-Sep-2019 07:33:28
Advertisements