Question

I have this program written and it runs, but was wondering if a pop() and push()...

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!

Homework Answers

Answer #1

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.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Given main() complete the Stack class by writing the methods push() and pop(). The stack uses...
Given main() complete the Stack class by writing the methods push() and pop(). The stack uses an array of size 5 to store elements. The command Push followed by a positive number pushes the number onto the stack. The command Pop pops the top element from the stack. Entering -1 exits the program. Ex. If the input is Push 1 Push 2 Push 3 Push 4 Push 5 Pop -1 the output is Stack contents (top to bottom): 1 Stack...
I need a program written in C, not C+ or C++. I have no idea how...
I need a program written in C, not C+ or C++. I have no idea how to go about doing it. Basically, I need it to take in the following information and spit out the following for a number table. The operation should be able to take plus, minus, division or multiplication and the low/high row/column numbers should be able to go up to where ever. But I'm sure the following example is fine. Enter low row number: 1 Enter...
(Hello, I am very confused in this discussion post that I was wondering if you can...
(Hello, I am very confused in this discussion post that I was wondering if you can give me another example, I am not exactly sure where to start) Give a unique example of a business transaction. Then explain and show the T-account info. Create a fictitious company, then create a fictitious scenario. Example: Owner invests $5,000. Analysis: Since money is deposited into the checking account, Cash is debited (the balance increased by $5,000). What account receives a credit? An Equity...
(Hello, I am very confused in this discussion post that I was wondering if you can...
(Hello, I am very confused in this discussion post that I was wondering if you can give me another example, I am not exactly sure where to start) Give a unique example of a business transaction. Then explain and show the T-account info. Create a fictitious company, then create a fictitious scenario.   Example: Owner invests $5,000.   Analysis: Since money is deposited into the checking account, Cash is debited (the balance increased by $5,000). What account receives a credit? An Equity account...
I was wondering how to answer this question During the last 30 years computers have changed...
I was wondering how to answer this question During the last 30 years computers have changed most production processes. Use isocost-isoquant diagram analysis to show the effect the spread of computers have had on labour use during the last 30 years. Make sure you list your assumptions clearly.
This is not for an assignment, but for my own understanding and I was wondering if...
This is not for an assignment, but for my own understanding and I was wondering if anyone would be able to assist me with understanding. Consider a non-trivial trajectory where the velocity & acceleration of some charged particle are non-zero. If i were wanting to plot the electric and magnetic field, how would I go about making the equation to do so? Would you be able to give me an example? If I wanted to convert a 2 dimensional plot...
Write a program in Java that: 1. will prompt user with a menu that contains options...
Write a program in Java that: 1. will prompt user with a menu that contains options to: a. Add a To-Do Item to a todo list. A To-Do Item contains: i. An arbitrary reference number (4; 44,004; etc.) ii. A text description of the item ("Pick up dry cleaning", etc.) iii. A priority level (1, 2, 3, 4, or 5) b. View an item in the list (based on its reference number) c. Delete an item from the list (based...
There is a paper I have to write for management theory but I am confused. I...
There is a paper I have to write for management theory but I am confused. I was wondering if you can help me. Provide an example of a "Change" you experienced in the organization. Utilize the Change Cycle to explain each area of the change and was the change successful or unsuccessful and why? Thank you so much for your help!
Java program question! If I pass null to a method, how can I use the passed...
Java program question! If I pass null to a method, how can I use the passed value to compare. Here is example code, it might be wrong, please make it could run on eclipse. Public class hw{ public static void main (String args[]) { method1(); } private static void method1() { System.out.println(method(null)); } public static String method(int[] a) { return null; } What I want to get in the output is just "()". It is not just to type the...
C++ PROGRAMMING Hi! I have to make a program that adds fractions and simplifies them. I...
C++ PROGRAMMING Hi! I have to make a program that adds fractions and simplifies them. I feel like I know how to write that. What I'm having trouble with is implementing two files the professer gave us. I would appreicate any help in understanding their purpose as in if Im supposed to take information from those files or give it information. Thank you! I have attatched the homework instructions and the two files given. Implementation The main program, called calculator.cpp...