Ask Question
Today, 15:52

Create a stack with three integers and then use. toarray to copy it to an array.

+5
Answers (1)
  1. Today, 18:26
    0
    import java. util.*;

    import java. lang.*;

    import java. io.*;

    class Codechef

    {

    public static void main (String[] args)

    {

    Stack mat=new Stack ();

    mat. add (1);

    mat. add (3);

    mat. add (6);

    System. out. println (mat);

    Object [] a=mat. toArray ();

    for (int i=0; i
    System. out. println (a[i]);

    }

    }

    Explanation:

    An integer type stack st is created;

    1,3 and 6 are added to the stack.

    printing the contents of the stack.

    array a is created form the stack using toArray ().

    Then printing the array.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Create a stack with three integers and then use. toarray to copy it to an array. ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers