I have this program written and it runs, but was wondering if a pop() and push() methods could be implemented instead of poll() in the DogSalon Class? If there is a way could you explain and show an example? Thanks!
pop() method used to remove the element in stack or queue
in same way,
poll () method is basically used to retrive or remove the head of this queue or return null .
so these two methods are similer but there is a small difference,
lets take an example,
if your list contains N numbers of elements then this two methods remove the element or retrive them,but
if your list is empty then,
if you use poll() method then it will return NULL because the list is empty,
but if you use pop() method then it will throw an NoSuchElementException() in empty list insted of returnig NULL.
Get Answers For Free
Most questions answered within 1 hours.