Ask Question
6 May, 00:14

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

+3
Answers (1)
  1. 6 May, 01:34
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers