I have two stacks I have to create the third one interleaving the values of the two stacks I created the stack and all I'm having a lock to implement is the code to interleave
follow the code:
public class Pilha {
private Stack p;
public Pilha()
{
p = new Stack();
}
public void insere(int x)
{
p.push(x);
}
public int remove()
{
return (int) p.pop();
}
}
public static void main(String[] args) {
// TODO code application logic here
int a=2, b=3, c=4, d=5,e=6,f=7,g=8,h=9;
Pilha p1 = new Pilha();
Pilha p2 = new Pilha();
Pilha p3 = new Pilha();
p1.insere(a);
p1.insere(b);
p1.insere(c);
p1.insere(d);
p2.insere(e);
p2.insere(f);
p2.insere(g);
p2.insere(h);