Ask Question

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

+1
Answers (1)
  1. 22 June, 22:01
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers