Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Implement Ennead Class from Octet Class in Java using JavaTuples

  • Last Updated : 24 Sep, 2018

Prerequisite: Ennead Class, Octet Class

Below are the methods to implement a Ennead Class using Octet Class in Java:

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

  1. Using direct values




    // Java program to illustrate
    // implementing Ennead Class 
    // from Octet Class 
    // using direct values
      
    import java.util.*;
    import org.javatuples.*;
      
    class GfG {
      
        public static void main(String[] args)
        {
            // Create Octet
            Octet<String, String, String, String, String, String, String, String>
                octet = new Octet<String, String, String, String, String, String, String, String>(
                    "Octet", "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Octet
            System.out.println("Octet: " + octet);
      
            // Create Ennead from Octet
            Ennead<String, String, String, String, String, String, String, String, String>
                ennead = new Ennead<String, String, String, String, String, String, String, String, String>(
                    "Ennead",
                    octet.getValue0(),
                    octet.getValue1(),
                    octet.getValue2(),
                    octet.getValue3(),
                    octet.getValue4(),
                    octet.getValue5(),
                    octet.getValue6(),
                    octet.getValue7());
      
            // Print the Ennead
            System.out.println("Ennead: " + ennead);
        }
    }

    Output:

    Octet: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Ennead: [Ennead, Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    
  2. Using Octet.add() method




    // Java program to illustrate
    // implementing Ennead Class 
    // from Octet Class 
    // using Octet.add()
      
    import java.util.*;
    import org.javatuples.*;
      
    class GfG {
        public static void main(String[] args)
        {
            // Create Octet
            Octet<String, String, String, String, String, String, String, String>
                octet = new Octet<String, String, String, String, String, String, String, String>(
                    "Octet", "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Octet
            System.out.println("Octet: " + octet);
      
            // Create Ennead from Octet
            Ennead<String, String, String, String, String, String, String, String, String>
                ennead = octet.add("Ennead");
      
            // Print the Ennead
            System.out.println("Ennead: " + ennead);
        }
    }

    Output:



    Octet: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Ennead: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit, Ennead]
    
  3. Using Octet.addAtX() method

    Program 1: Adding at Position 0 using addAt0()




    // Java program to illustrate
    // implementing Ennead Class 
    // from Octet Class 
    // using addAtx()
      
    import java.util.*;
    import org.javatuples.*
      
        class GfG {
        public static void main(String[] args)
        {
           // Create Octet
            Octet<String, String, String, String, String, String, String, String>
                octet = new Octet<String, String, String, String, String, String, String, String>(
                    "Octet", "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Octet
            System.out.println("Octet: " + octet);
      
            // Create Ennead from Octet
            Ennead<String, String, String, String, String, String, String, String, String>
                ennead = octet.addAt0("Ennead");
      
            // Print the Ennead
            System.out.println("Ennead: " + ennead);
        }
    }

    Output:

    Octet: [Octet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Ennead: [Ennead, Octet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    

    Program 2: Adding at Position 1 using addAt1()




    // Java program to illustrate
    // implementing Ennead Class 
    // from Octet Class 
    // using addAt1()
      
    import java.util.*;
    import org.javatuples.*;
      
    class GfG {
        public static void main(String[] args)
        {
            // Create Octet
            Octet<String, String, String, String, String, String, String, String>
                octet = new Octet<String, String, String, String, String, String, String, String>(
                    "Octet", "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Octet
            System.out.println("Octet: " + octet);
      
            // Create Ennead from Octet
            Ennead<String, String, String, String, String, String, String, String, String>
                ennead = octet.addAt1("Ennead");
      
            // Print the Ennead
            System.out.println("Ennead: " + ennead);
        }
    }

    Output:

    Octet: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Ennead: [Octet, Ennead, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    

    Program 3: Adding at Position 2 using addAt2()




    // Below is a Java program to demonstrate
    // use of addAt2() method with
    // direct value
      
    import java.util.*;
    import org.javatuples.*
      
        class GfG {
        public static void main(String[] args)
        {
            // Create Octet
            Octet<String, String, String, String, String, String, String, String>
                octet = new Octet<String, String, String, String, String, String, String, String>(
                    "Octet", "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Octet
            System.out.println("Octet: " + octet);
      
            // Create Ennead from Octet
            Ennead<String, String, String, String, String, String, String, String, String>
                ennead = octet.addAt2("Ennead");
      
            // Print the Ennead
            System.out.println("Ennead: " + ennead);
        }
    }

    Output:

    Octet: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Ennead: [Octet, Septet, Ennead, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    

    Program 4: Adding at Position 3 using addAt3()




    // Below is a Java program to demonstrate
    // use of addAt3() method with
    // direct value
      
    import java.util.*;
    import org.javatuples.*
      
        class GfG {
        public static void main(String[] args)
        {
            // Create Octet
            Octet<String, String, String, String, String, String, String, String>
                octet = new Octet<String, String, String, String, String, String, String, String>(
                    "Octet", "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Octet
            System.out.println("Octet: " + octet);
      
            // Create Ennead from Octet
            Ennead<String, String, String, String, String, String, String, String, String>
                ennead = octet.addAt3("Ennead");
      
            // Print the Ennead
            System.out.println("Ennead: " + ennead);
        }
    }

    Output:



    Octet: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Ennead: [Octet, Septet, Sextet, Ennead, Quintet, Quartet, Triplet, Pair, Unit]
    

    Program 5: Adding at Position 4 using addAt4()




    // Below is a Java program to demonstrate
    // use of addAt4() method with
    // direct value
      
    import java.util.*;
    import org.javatuples.*
      
       class GfG {
        public static void main(String[] args)
        {
            // Create Octet
            Octet<String, String, String, String, String, String, String, String>
                octet = new Octet<String, String, String, String, String, String, String, String>(
                    "Octet", "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Octet
            System.out.println("Octet: " + octet);
      
            // Create Ennead from Octet
            Ennead<String, String, String, String, String, String, String, String, String>
                ennead = octet.addAt4("Ennead");
      
            // Print the Ennead
            System.out.println("Ennead: " + ennead);
        }
    }

    Output:

    Octet: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Ennead: [Octet, Septet, Sextet, Quintet, Ennead, Quartet, Triplet, Pair, Unit]
    

    Program 6: Adding at Position 5 using addAt5()




    // Below is a Java program to demonstrate
    // use of addAt5() method with
    // direct value
      
    import java.util.*;
    import org.javatuples.*
      
        class GfG {
        public static void main(String[] args)
        {
            // Create Octet
            Octet<String, String, String, String, String, String, String, String>
                octet = new Octet<String, String, String, String, String, String, String, String>(
                    "Octet", "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Octet
            System.out.println("Octet: " + octet);
      
            // Create Ennead from Octet
            Ennead<String, String, String, String, String, String, String, String, String>
                ennead = octet.addAt5("Ennead");
      
            // Print the Ennead
            System.out.println("Ennead: " + ennead);
        }
    }

    Output:

    Octet: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Ennead: [Octet, Septet, Sextet, Quintet, Quartet, Ennead, Triplet, Pair, Unit]
    

    Program 7: Adding at Position 6 using addAt6()




    // Below is a Java program to demonstrate
    // use of addAt6() method with
    // direct value
      
    import java.util.*;
    import org.javatuples.*
      
       class GfG {
        public static void main(String[] args)
        {
            // Create Octet
            Octet<String, String, String, String, String, String, String, String>
                octet = new Octet<String, String, String, String, String, String, String, String>(
                    "Octet", "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Octet
            System.out.println("Octet: " + octet);
      
            // Create Ennead from Octet
            Ennead<String, String, String, String, String, String, String, String, String>
                ennead = octet.addAt6("Ennead");
      
            // Print the Ennead
            System.out.println("Ennead: " + ennead);
        }
    }

    Output:

    Octet: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Ennead: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Ennead, Pair, Unit]
    

    Program 8: Adding at Position 7 using addAt7()




    // Below is a Java program to demonstrate
    // use of addAt7() method with
    // direct value
      
    import java.util.*;
    import org.javatuples.*
      
       class GfG {
        public static void main(String[] args)
        {
            // Create Octet
            Octet<String, String, String, String, String, String, String, String>
                octet = new Octet<String, String, String, String, String, String, String, String>(
                    "Octet", "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Octet
            System.out.println("Octet: " + octet);
      
            // Create Ennead from Octet
            Ennead<String, String, String, String, String, String, String, String, String>
                ennead = octet.addAt7("Ennead");
      
            // Print the Ennead
            System.out.println("Ennead: " + ennead);
        }
    }

    Output:

    Octet: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Ennead: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Ennead, Unit]
    

    Program 9: Adding at Position 8 using addAt8()




    // Below is a Java program to demonstrate
    // use of addAt8() method with
    // direct value
      
    import java.util.*;
    import org.javatuples.*
      
       class GfG {
        public static void main(String[] args)
        {
            // Create Octet
            Octet<String, String, String, String, String, String, String, String>
                octet = new Octet<String, String, String, String, String, String, String, String>(
                    "Octet", "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Octet
            System.out.println("Octet: " + octet);
      
            // Create Ennead from Octet
            Ennead<String, String, String, String, String, String, String, String, String>
                ennead = octet.addAt8("Ennead");
      
            // Print the Ennead
            System.out.println("Ennead: " + ennead);
        }
    }

    Output:

    Octet: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Ennead: [Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit, Ennead]
    



    My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!