Skip to content
Related Articles

Related Articles

Improve Article

Implement Decade Class from Ennead Class in Java using JavaTuples

  • Last Updated : 24 Sep, 2018
Geek Week

Prerequisite: Decade Class, Ennead Class

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

  1. Using direct values




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

    Output:

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




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

    Output:

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

    Program 1: Adding at Position 0 using addAt0()






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

    Output:

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

    Program 2: Adding at Position 1 using addAt1()




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

    Output:

    Ennead: [Ennead, Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Decade: [Ennead, Decade, Octet, 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 Ennead
            Ennead<String, String, String, String, String, String, String, String, String>
                ennead = new Ennead<String, String, String, String, String, String, String, String, String>(
                    "Ennead", "Octet", "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Ennead
            System.out.println("Ennead: " + ennead);
      
            // Create Decade from Ennead
            Decade<String, String, String, String, String, String, String, String, String, String>
                decade = ennead.addAt2("Decade");
      
            // Print the Decade
            System.out.println("Decade: " + decade);
        }
    }

    Output:

    Ennead: [Ennead, Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Decade: [Ennead, Octet, Decade, Septet, 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 Ennead
            Ennead<String, String, String, String, String, String, String, String, String>
                ennead = new Ennead<String, String, String, String, String, String, String, String, String>(
                    "Ennead", "Octet", "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Ennead
            System.out.println("Ennead: " + ennead);
      
            // Create Decade from Ennead
            Decade<String, String, String, String, String, String, String, String, String, String>
                decade = ennead.addAt3("Decade");
      
            // Print the Decade
            System.out.println("Decade: " + decade);
        }
    }

    Output:

    Ennead: [Ennead, Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Decade: [Ennead, Octet, Septet, Decade, Sextet, 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 Ennead
            Ennead<String, String, String, String, String, String, String, String, String>
                ennead = new Ennead<String, String, String, String, String, String, String, String, String>(
                    "Ennead", "Octet", "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Ennead
            System.out.println("Ennead: " + ennead);
      
            // Create Decade from Ennead
            Decade<String, String, String, String, String, String, String, String, String, String>
                decade = ennead.addAt4("Decade");
      
            // Print the Decade
            System.out.println("Decade: " + decade);
        }
    }

    Output:

    Ennead: [Ennead, Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Decade: [Ennead, Octet, Septet, Sextet, Decade, Quintet, 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 Ennead
            Ennead<String, String, String, String, String, String, String, String, String>
                ennead = new Ennead<String, String, String, String, String, String, String, String, String>(
                    "Ennead", "Octet", "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Ennead
            System.out.println("Ennead: " + ennead);
      
            // Create Decade from Ennead
            Decade<String, String, String, String, String, String, String, String, String, String>
                decade = ennead.addAt5("Decade");
      
            // Print the Decade
            System.out.println("Decade: " + decade);
        }
    }

    Output:

    Ennead: [Ennead, Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Decade: [Ennead, Octet, Septet, Sextet, Quintet, Decade, Quartet, 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 Ennead
            Ennead<String, String, String, String, String, String, String, String, String>
                ennead = new Ennead<String, String, String, String, String, String, String, String, String>(
                    "Ennead", "Octet", "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Ennead
            System.out.println("Ennead: " + ennead);
      
            // Create Decade from Ennead
            Decade<String, String, String, String, String, String, String, String, String, String>
                decade = ennead.addAt6("Decade");
      
            // Print the Decade
            System.out.println("Decade: " + decade);
        }
    }

    Output:

    Ennead: [Ennead, Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Decade: [Ennead, Octet, Septet, Sextet, Quintet, Quartet, Decade, Triplet, 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 Ennead
            Ennead<String, String, String, String, String, String, String, String, String>
                ennead = new Ennead<String, String, String, String, String, String, String, String, String>(
                    "Ennead", "Octet", "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Ennead
            System.out.println("Ennead: " + ennead);
      
            // Create Decade from Ennead
            Decade<String, String, String, String, String, String, String, String, String, String>
                decade = ennead.addAt7("Decade");
      
            // Print the Decade
            System.out.println("Decade: " + decade);
        }
    }

    Output:

    Ennead: [Ennead, Octet, Septet, Sextet, Quintet, Quartet, Triplet, Pair, Unit]
    Decade: [Ennead, Octet, Septet, Sextet, Quintet, Quartet, Triplet, Decade, Pair, 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 Ennead
            Ennead<String, String, String, String, String, String, String, String, String>
                ennead = new Ennead<String, String, String, String, String, String, String, String, String>(
                    "Ennead", "Octet", "Septet", "Sextet", "Quintet", "Quartet", "Triplet", "Pair", "Unit");
      
            // Print the Ennead
            System.out.println("Ennead: " + ennead);
      
            // Create Decade from Ennead
            Decade<String, String, String, String, String, String, String, String, String, String>
                decade = ennead.addAt8("Decade");
      
            // Print the Decade
            System.out.println("Decade: " + decade);
        }
    }

    Output:

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

    Program 10: Adding at Position 9 using addAt9()




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

    Output:

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

    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.




    My Personal Notes arrow_drop_up
Recommended Articles
Page :