i'm creating the method toArray in the code below, getting cannot find symbol error in calling both pop() and push() methods inside toArray. Why?
public void push(Comparable x)
{
arr[size++] = x;
}
public Object pop() throws EmptyStackException
{
return arr[size--];
}
public Comparable[] toArray()
{
Comparable[] newarr = new Comparable[size];
for(int i = 0; i < size; i++)
{
newarr[i] = arr.pop();
}
for(int i = size; i > 0; i--)
{
arr.push(newarr[i-1]);
}
return newarr;
}